AppendOrder.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * 订单追加服务表
  4. */
  5. class AppendOrder extends MongoAr
  6. {
  7. public $_id;
  8. public $order;
  9. public $charge_id;//ping++的chargeId,charge_id即为支付单号
  10. public $pay_channel;//支付渠道
  11. public $append_time;//追加时间
  12. public $products=array(); //订单包含的商品数组 数据库设计 支持多个产品在一个订单
  13. public $price; //订单金额
  14. public $status=0;//状态 0=>待支付 1=>已支付 -1=>已退款
  15. public function __construct($scenario='insert'){
  16. $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
  17. parent::__construct($scenario);
  18. }
  19. public static $status_option = array(
  20. 0 => array('name' => '待支付'),
  21. 1 => array('name' => '已支付'),
  22. -1 => array('name' => '已退款'),
  23. );
  24. public static function model($className=__CLASS__)
  25. {
  26. return parent::model($className);
  27. }
  28. public static function get($_id) {
  29. if(CommonFn::isMongoId($_id)){
  30. $criteria = new EMongoCriteria();
  31. $criteria->_id('==', $_id);
  32. $model = self::model()->find($criteria);
  33. return $model;
  34. }else{
  35. return false;
  36. }
  37. }
  38. public function getCollectionName()
  39. {
  40. return 'append_order';
  41. }
  42. public function parseRow($row,$output=array()){
  43. $newRow = array();
  44. $newRow['id'] = (string)$row['_id'];
  45. $newRow['order'] = (string)CommonFn::get_val_if_isset($row,'order','');
  46. $newRow['pay_channel'] = CommonFn::get_val_if_isset($row,'pay_channel','');
  47. $newRow['charge_id'] = CommonFn::get_val_if_isset($row,'charge_id','');
  48. $newRow['price'] = CommonFn::get_val_if_isset($row,'price','');
  49. $newRow['status'] = CommonFn::get_val_if_isset($row,'status',0);
  50. $newRow['status_str'] = self::$status_option[$newRow['status']]['name'];
  51. if($newRow['status'] == 1){
  52. $newRow['book_status_str'] = '已支付';
  53. }elseif ($newRow['status'] == 0) {
  54. $newRow['book_status_str'] = '未支付';
  55. }
  56. $products = array();
  57. $newRow['products_str'] = '';
  58. if(isset($row['products'])&&is_array($row['products'])){
  59. foreach ($row['products'] as $key => $product) {
  60. $product_obj = Product::get($product['product']);
  61. $temp_info = $product_obj->parseRow($product_obj);
  62. $temp_info['count'] = $product['count'];
  63. $products[] = $temp_info;
  64. if($key == 0){
  65. $newRow['products_str'] .= $temp_info['name'];
  66. }else{
  67. $newRow['products_str'] .= '+'.$temp_info['name'];
  68. }
  69. }
  70. }
  71. $newRow['products'] = $products;
  72. if(!isset($newRow['products'])||empty($newRow['products'])){
  73. $newRow['products']=CommonFn::$empty;
  74. }
  75. $newRow['append_time'] = CommonFn::get_val_if_isset($row,'append_time',0);
  76. $newRow['append_time_str'] = date('n月d日 H:i',$newRow['append_time']);
  77. $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
  78. $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
  79. $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
  80. if(APPLICATION=='api'){
  81. unset($newRow['action_user']);
  82. unset($newRow['action_time']);
  83. unset($newRow['action_log']);
  84. }
  85. return $this->output($newRow,$output);
  86. }
  87. }