Memberorder.php 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. use think\facade\Db;
  5. /**
  6. * ============================================================================
  7. * DSMall多用户商城
  8. * ============================================================================
  9. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  10. * 网站地址: http://www.csdeshang.com
  11. * ----------------------------------------------------------------------------
  12. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  13. * 不允许对程序代码以任何形式任何目的的再发布。
  14. * ============================================================================
  15. * 订单控制器
  16. */
  17. class Memberorder extends MobileMember
  18. {
  19. public function initialize()
  20. {
  21. parent::initialize();
  22. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/memberorder.lang.php');
  23. }
  24. /**
  25. * @api {POST} api/Memberorder/order_list 订单列表
  26. * @apiVersion 1.0.0
  27. * @apiGroup MemberOrder
  28. *
  29. * @apiHeader {String} X-DS-KEY 用户授权token
  30. *
  31. * @apiParam {Int} page 当前页数
  32. * @apiParam {Int} state_type 订单状态
  33. * @apiParam {String} order_key 订单编号
  34. * @apiParam {Int} per_page 每页数量
  35. *
  36. * @apiSuccess {String} code 返回码,10000为成功
  37. * @apiSuccess {String} message 返回消息
  38. * @apiSuccess {Object} result 返回数据
  39. * @apiSuccess {Object[]} result.order_group_list 订单组列表
  40. * @apiSuccess {Int} result.order_group_list.add_time 添加时间
  41. * @apiSuccess {Object[]} result.order_group_list.order_list 订单列表
  42. * @apiSuccess {Int} result.order_group_list.order_list.add_time 退款添加时间
  43. * @apiSuccess {String} result.order_group_list.order_list.buyer_email 买家邮箱
  44. * @apiSuccess {Int} result.order_group_list.order_list.buyer_id 买家ID
  45. * @apiSuccess {String} result.order_group_list.order_list.buyer_name 买家用户名
  46. * @apiSuccess {Int} result.order_group_list.order_list.delay_time 自动收货时间
  47. * @apiSuccess {Int} result.order_group_list.order_list.delete_state 订单删除状态 0:未删除 1:放入回收站 2:彻底删除
  48. * @apiSuccess {Int} result.order_group_list.order_list.evaluation_state 评论状态
  49. * @apiSuccess {Object} result.order_group_list.order_list.extend_order_common 订单公共信息
  50. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.daddress_id 发货地址ID
  51. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.deliver_explain 订单发货备注
  52. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.evalseller_state 卖家是否已评价买家
  53. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.evalseller_time 卖家评价买家的时间
  54. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.evaluation_time 评价时间
  55. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.invoice_info 订单发票信息
  56. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.order_id 订单ID
  57. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.order_message 订单留言
  58. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.order_pointscount 订单赠送积分
  59. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.promotion_info 订单促销信息备注
  60. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.reciver_city_id 收货人市级ID
  61. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info 收货人其它信息
  62. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info.address 收货地址
  63. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info.area 收货地区
  64. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info.mob_phone 收货人手机号
  65. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info.phone 收货人联系号码
  66. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info.street 街道地址
  67. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_info.tel_phone 座机号
  68. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.reciver_name 收货人姓名
  69. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.reciver_province_id 收货地区省ID
  70. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.shipping_express_id 配送公司ID
  71. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.shipping_time 发货时间
  72. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.store_id 店铺ID
  73. * @apiSuccess {String} result.order_group_list.order_list.extend_order_common.voucher_code 代金券编码
  74. * @apiSuccess {Int} result.order_group_list.order_list.extend_order_common.voucher_price 代金券面额
  75. * @apiSuccess {Object} result.order_group_list.order_list.extend_store 店铺信息
  76. * @apiSuccess {String} result.order_group_list.order_list.extend_store.area_info 店铺地区
  77. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.bind_all_gc 是否绑定所有分类 0否1是
  78. * @apiSuccess {String} result.order_group_list.order_list.extend_store.deliver_region 店铺默认配送区域
  79. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.goods_count 商品数量
  80. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.grade_id 等级ID
  81. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.is_platform_store 是否自营店 0否1是
  82. * @apiSuccess {String} result.order_group_list.order_list.extend_store.mb_sliders 手机店铺轮播图序列化字符串
  83. * @apiSuccess {String} result.order_group_list.order_list.extend_store.mb_title_img 手机店铺背景图
  84. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.member_id 店铺用户ID
  85. * @apiSuccess {String} result.order_group_list.order_list.extend_store.member_name 店铺用户名
  86. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.region_id 店铺地区ID
  87. * @apiSuccess {String} result.order_group_list.order_list.extend_store.seller_name 卖家用户名
  88. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_address 店铺地址
  89. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_addtime 店铺添加时间
  90. * @apiSuccess {Object[]} result.order_group_list.order_list.extend_store.store_aftersales 售后列表
  91. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_aftersales.name 售后名称
  92. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_aftersales.num 售后账号
  93. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_aftersales.type 售后类型 1QQ2旺旺3站内IM
  94. * @apiSuccess {Float} result.order_group_list.order_list.extend_store.store_avaliable_deposit 可用保证金
  95. * @apiSuccess {Float} result.order_group_list.order_list.extend_store.store_avaliable_money 可用预存款
  96. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_avatar 店铺头像
  97. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_banner 店铺背景图
  98. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_baozh 是否已缴保证金 0否1是
  99. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_bill_time 上次结算时间
  100. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_close_info 店铺关闭原因
  101. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_collect 店铺收藏数量
  102. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_company_name 店铺公司名称
  103. * @apiSuccess {Object} result.order_group_list.order_list.extend_store.store_credit 店铺信用信息
  104. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_credit.store_deliverycredit 发货速度信息
  105. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_credit.store_deliverycredit.credit 发货速度评分
  106. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_credit.store_deliverycredit.text 发货速度描述
  107. * @apiSuccess {Object} result.order_group_list.order_list.extend_store.store_credit.store_desccredit 描述相符信息
  108. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_credit.store_desccredit.credit 描述相符评分
  109. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_credit.store_desccredit.text 描述相符描述
  110. * @apiSuccess {Object} result.order_group_list.order_list.extend_store.store_credit.store_servicecredit 服务态度信息
  111. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_credit.store_servicecredit.credit 服务态度评分
  112. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_credit.store_servicecredit.text 服务态度描述
  113. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_credit_average 平均评分
  114. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_credit_percent 好评率
  115. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_deliverycredit 发货速度评分
  116. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_desccredit 描述相符评分
  117. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_description 店铺SEO描述
  118. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_endtime 店铺到期时间
  119. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_erxiaoshi 是否两小时发货 0否1是
  120. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_free_price 超出该金额免运费 0未设置
  121. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_free_time 商家配送时间
  122. * @apiSuccess {Float} result.order_group_list.order_list.extend_store.store_freeze_deposit 冻结保证金
  123. * @apiSuccess {Float} result.order_group_list.order_list.extend_store.store_freeze_money 冻结预存款
  124. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_huodaofk 是否支持货到付款 0否1是
  125. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_id 店铺ID
  126. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_keywords 店铺SEO关键字
  127. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_latitude 纬度
  128. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_logo 店铺logo
  129. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_longitude 经度
  130. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_mainbusiness 主营商品
  131. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_mgdiscount 序列化会员等级折扣
  132. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_mgdiscount_state 店铺是否开启序列化会员等级折扣 0否1是
  133. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_name 店铺名称
  134. * @apiSuccess {Float} result.order_group_list.order_list.extend_store.store_payable_deposit 应缴保证金
  135. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_phone 店铺电话
  136. * @apiSuccess {Object[]} result.order_group_list.order_list.extend_store.store_presales 售前列表
  137. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_presales.name 售前名称
  138. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_presales.num 售前账号
  139. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_presales.type 售前类型 1QQ2旺旺3站内IM
  140. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_printexplain 打印订单页面下方说明文字
  141. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_qq 店铺QQ
  142. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_qtian 是否支持7天退换 0否1是
  143. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_recommend 推荐店铺 0否1是
  144. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_sales 销量
  145. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_servicecredit 服务态度评分
  146. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_shiti 实体店认证 0否1是
  147. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_shiyong 是否支持试用 0否1是
  148. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_slide 店铺幻灯片
  149. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_slide_url 店铺幻灯片链接
  150. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_sort 店铺排序
  151. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_state 店铺状态 0关闭,1开启,2审核中
  152. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_tuihuo 是否支持退货承诺 0否1是
  153. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_vrcode_prefix 商家兑换码前缀
  154. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_workingtime 工作时间
  155. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_ww 店铺旺旺
  156. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_xiaoxie 是否消协保证 0否1是
  157. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.store_zhping 是否正品保障 0否1是
  158. * @apiSuccess {String} result.order_group_list.order_list.extend_store.store_zip 邮政编码
  159. * @apiSuccess {Int} result.order_group_list.order_list.extend_store.storeclass_id 店铺分类ID
  160. * @apiSuccess {Int} result.order_group_list.order_list.finnshed_time 订单完成时间
  161. * @apiSuccess {Float} result.order_group_list.order_list.goods_amount 商品总额
  162. * @apiSuccess {Int} result.order_group_list.order_list.if_cancel 是否可取消 true是false否
  163. * @apiSuccess {Int} result.order_group_list.order_list.if_delete 是否可删除 true是false否
  164. * @apiSuccess {Int} result.order_group_list.order_list.if_deliver 是否可发货 true是false否
  165. * @apiSuccess {Int} result.order_group_list.order_list.if_evaluation 是否可评价 true是false否
  166. * @apiSuccess {Int} result.order_group_list.order_list.if_lock 是否被锁定 true是false否
  167. * @apiSuccess {Int} result.order_group_list.order_list.if_receive 是否可收货 true是false否
  168. * @apiSuccess {Int} result.order_group_list.order_list.if_refund_cancel 是否可全部退款 true是false否
  169. * @apiSuccess {Int} result.order_group_list.order_list.lock_state 锁定状态:0:正常,大于0:锁定
  170. * @apiSuccess {Int} result.order_group_list.order_list.ob_no 结算单号
  171. * @apiSuccess {Float} result.order_group_list.order_list.order_amount 订单总金额
  172. * @apiSuccess {Int} result.order_group_list.order_list.order_from 订单来源,1:PC 2:手机
  173. * @apiSuccess {Int} result.order_group_list.order_list.order_id 订单ID
  174. * @apiSuccess {String} result.order_group_list.order_list.order_sn 订单编号
  175. * @apiSuccess {Int} result.order_group_list.order_list.order_state 订单状态
  176. * @apiSuccess {Int} result.order_group_list.order_list.order_type 订单类型
  177. * @apiSuccess {String} result.order_group_list.order_list.pay_sn 支付单号
  178. * @apiSuccess {String} result.order_group_list.order_list.payment_code 支付方式代码
  179. * @apiSuccess {String} result.order_group_list.order_list.payment_name 支付方式名称
  180. * @apiSuccess {Int} result.order_group_list.order_list.payment_time 支付时间
  181. * @apiSuccess {Float} result.order_group_list.order_list.pd_amount 使用预存款金额
  182. * @apiSuccess {Float} result.order_group_list.order_list.rcb_amount 使用充值卡金额
  183. * @apiSuccess {Float} result.order_group_list.order_list.refund_amount 退款金额
  184. * @apiSuccess {Int} result.order_group_list.order_list.refund_state 退款状态 0:无退款 1:部分退款 2:全部退款
  185. * @apiSuccess {String} result.order_group_list.order_list.shipping_code 发货运单号
  186. * @apiSuccess {Float} result.order_group_list.order_list.shipping_fee 运费
  187. * @apiSuccess {String} result.order_group_list.order_list.state_desc 状态描述
  188. * @apiSuccess {Int} result.order_group_list.order_list.store_id 店铺ID
  189. * @apiSuccess {String} result.order_group_list.order_list.store_name 店铺名称
  190. * @apiSuccess {Int} result.order_group_list.pay_amount 支付时间
  191. * @apiSuccess {String} result.order_group_list.pay_sn 支付单号
  192. * @apiSuccess {Int} result.page_total 总页数
  193. * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
  194. */
  195. public function order_list()
  196. {
  197. $order_model = model('order');
  198. $condition = [];
  199. $condition = $this->order_type_no(input('post.state_type'));
  200. $condition[] = ['buyer_id', '=', $this->member_info['member_id']];
  201. $condition[] = ['delete_state', '=', 0]; #订单未被删除
  202. $order_sn = input('post.order_key');
  203. if ($order_sn != '') {
  204. $condition[] = ['order_sn', 'like', '%' . $order_sn . '%'];
  205. }
  206. $refundreturn_model = model('refundreturn');
  207. $order_list_array = $order_model->getOrderList($condition, 5, '*', 'order_id desc', 0, ['order_common', 'order_goods', 'store']);
  208. $order_list_array = $refundreturn_model->getGoodsRefundList($order_list_array, 1); //订单商品的退款退货显示
  209. $order_group_list = $order_pay_sn_array = [];
  210. foreach ($order_list_array as $value) {
  211. //$value['zengpin_list'] = false;
  212. //显示取消订单
  213. $value['if_cancel'] = $order_model->getOrderOperateState('buyer_cancel', $value);
  214. //显示退款取消订单
  215. $value['if_refund_cancel'] = $order_model->getOrderOperateState('refund_cancel', $value);
  216. //显示收货
  217. $value['if_receive'] = $order_model->getOrderOperateState('receive', $value);
  218. //显示投诉
  219. $order_info['if_complain'] = $order_model->getOrderOperateState('complain', $value);
  220. //显示锁定中
  221. $value['if_lock'] = $order_model->getOrderOperateState('lock', $value);
  222. //显示物流跟踪
  223. $value['if_deliver'] = $order_model->getOrderOperateState('deliver', $value);
  224. $value['if_evaluation'] = $order_model->getOrderOperateState('evaluation', $value);
  225. $value['if_delete'] = $order_model->getOrderOperateState('delete', $value);
  226. $value['ownshop'] = true;
  227. $value['zengpin_list'] = false;
  228. if (isset($value['extend_order_goods'])) {
  229. foreach ($value['extend_order_goods'] as $val) {
  230. $val['image_240_url'] = goods_cthumb($val['goods_image'], 240, $val['store_id']);
  231. $val['image_url'] = goods_cthumb($val['goods_image'], 240, $val['store_id']);
  232. $val['goods_type_cn'] = get_order_goodstype($val['goods_type']);
  233. if ($val['goods_type'] == 5) {
  234. $value['zengpin_list'][] = $val;
  235. }
  236. }
  237. }
  238. //商品图
  239. if (isset($value['extend_order_goods'])) {
  240. foreach ($value['extend_order_goods'] as $k => $goods_info) {
  241. if ($goods_info['goods_type'] == 5) {
  242. unset($value['extend_order_goods'][$k]);
  243. } else {
  244. $value['extend_order_goods'][$k] = $goods_info;
  245. $value['extend_order_goods'][$k]['goods_image_url'] = goods_cthumb($goods_info['goods_image'], 240, $value['store_id']);
  246. }
  247. }
  248. }
  249. $order_group_list[$value['pay_sn']]['order_list'][] = $value;
  250. //如果有在线支付且未付款的订单则显示合并付款链接
  251. if ($value['order_state'] == ORDER_STATE_NEW || $value['order_state'] == ORDER_STATE_DEPOSIT || $value['order_state'] == ORDER_STATE_REST) {
  252. if (!isset($order_group_list[$value['pay_sn']]['pay_amount'])) {
  253. $order_group_list[$value['pay_sn']]['pay_amount'] = 0;
  254. }
  255. $order_group_list[$value['pay_sn']]['pay_amount'] += ($value['order_state'] == ORDER_STATE_DEPOSIT ? $value['presell_deposit_amount'] : $value['order_amount']) - $value['rcb_amount'] - $value['pd_amount'] - $value['deduction_amount'];
  256. }
  257. $order_group_list[$value['pay_sn']]['add_time'] = $value['add_time'];
  258. //记录一下pay_sn,后面需要查询支付单表
  259. $order_pay_sn_array[] = $value['pay_sn'];
  260. }
  261. $new_order_group_list = [];
  262. foreach ($order_group_list as $key => $value) {
  263. $value['pay_sn'] = strval($key);
  264. $new_order_group_list[] = $value;
  265. }
  266. $result = array_merge(['order_group_list' => $new_order_group_list], mobile_page($order_model->page_info));
  267. ds_json_encode(10000, '', $result);
  268. }
  269. private function order_type_no($stage)
  270. {
  271. $condition = [];
  272. switch ($stage) {
  273. case 'state_new':
  274. $condition[] = ['order_state', '=', '10'];
  275. break;
  276. case 'state_pay':
  277. $condition[] = ['order_state', '=', '20'];
  278. break;
  279. case 'state_send':
  280. $condition[] = ['order_state', '=', '30'];
  281. break;
  282. case 'state_finish':
  283. $condition[] = ['order_state', '=', '40'];
  284. $condition[] = ['refund_state', '=', 0];
  285. $condition[] = ['evaluation_state', '=', '0'];
  286. break;
  287. case 'state_noeval':
  288. $condition[] = ['order_state', '=', '40'];
  289. $condition[] = ['refund_state', '=', 0];
  290. $condition[] = ['evaluation_state', '=', '0'];
  291. break;
  292. }
  293. return $condition;
  294. }
  295. /**
  296. * @api {POST} api/Memberorder/order_cancel 取消订单
  297. * @apiVersion 1.0.0
  298. * @apiGroup MemberOrder
  299. *
  300. * @apiHeader {String} X-DS-KEY 用户授权token
  301. *
  302. * @apiParam {Int} order_id 订单号
  303. *
  304. * @apiSuccess {String} code 返回码,10000为成功
  305. * @apiSuccess {String} message 返回消息
  306. */
  307. public function order_cancel()
  308. {
  309. $order_model = model('order');
  310. $logic_order = model('order', 'logic');
  311. $order_id = intval(input('post.order_id'));
  312. $condition = [];
  313. $condition[] = ['order_id', '=', $order_id];
  314. $condition[] = ['buyer_id', '=', $this->member_info['member_id']];
  315. $order_info = $order_model->getOrderInfo($condition);
  316. $if_allow = $order_model->getOrderOperateState('buyer_cancel', $order_info);
  317. if (!$if_allow) {
  318. ds_json_encode(10001, lang('have_right_operate'));
  319. }
  320. try {
  321. Db::startTrans();
  322. $logic_order->changeOrderStateCancel($order_info, 'buyer', $this->member_info['member_name'], lang('other_reason'));
  323. $logic_order->orderCancelBack($order_info,$this->member_info);
  324. } catch (\Exception $e) {
  325. Db::rollback();
  326. ds_json_encode(10001, $e->getMessage());
  327. }
  328. Db::commit();
  329. ds_json_encode(10000, '', 1);
  330. }
  331. /**
  332. * @api {POST} api/Memberorder/order_receive 订单确认收货
  333. * @apiVersion 1.0.0
  334. * @apiGroup MemberOrder
  335. *
  336. * @apiHeader {String} X-DS-KEY 用户授权token
  337. *
  338. * @apiParam {Int} order_id 订单号
  339. *
  340. * @apiSuccess {String} code 返回码,10000为成功
  341. * @apiSuccess {String} message 返回消息
  342. */
  343. public function order_receive()
  344. {
  345. $order_model = model('order');
  346. $logic_order = model('order', 'logic');
  347. $order_id = intval(input('post.order_id'));
  348. $condition = [];
  349. $condition[] = ['order_id', '=', $order_id];
  350. $condition[] = ['buyer_id', '=', $this->member_info['member_id']];
  351. $order_info = $order_model->getOrderInfo($condition);
  352. $if_allow = $order_model->getOrderOperateState('receive', $order_info);
  353. if (!$if_allow) {
  354. ds_json_encode(10001, lang('have_right_operate'));
  355. }
  356. $result = $logic_order->changeOrderStateReceive($order_info, 'buyer', $this->member_info['member_name'], lang('receive_goods'));
  357. if (!$result['code']) {
  358. ds_json_encode(10001, $result['msg']);
  359. } else {
  360. ds_json_encode(10000, '', 1);
  361. }
  362. }
  363. /**
  364. * 回收站
  365. */
  366. public function order_delete()
  367. {
  368. $order_model = model('order');
  369. $logic_order = model('order', 'logic');
  370. $order_id = intval(input('post.order_id'));
  371. $condition = [];
  372. $condition[] = ['order_id', '=', $order_id];
  373. $condition[] = ['buyer_id', '=', $this->member_info['member_id']];
  374. $order_info = $order_model->getOrderInfo($condition);
  375. $if_allow = $order_model->getOrderOperateState('delete', $order_info);
  376. if (!$if_allow) {
  377. ds_json_encode(10001, lang('have_right_operate'));
  378. }
  379. $result = $logic_order->changeOrderStateRecycle($order_info, 'buyer', 'delete');
  380. if (!$result['code']) {
  381. ds_json_encode(10001, $result['msg']);
  382. } else {
  383. ds_json_encode(10000, '', 1);
  384. }
  385. }
  386. /**
  387. * @api {POST} api/Memberorder/search_deliver 物流跟踪
  388. * @apiVersion 1.0.0
  389. * @apiGroup Memberorder
  390. *
  391. * @apiHeader {String} X-DS-KEY 用户授权token
  392. *
  393. * @apiParam {String} order_id 订单id
  394. *
  395. * @apiSuccess {String} code 返回码,10000为成功
  396. * @apiSuccess {String} message 返回消息
  397. * @apiSuccess {Object} result 返回数据
  398. * @apiSuccess {String} result.express_name 物流公司名称
  399. * @apiSuccess {String} result.shipping_code 物流单号
  400. * @apiSuccess {Object[]} result.deliver_info 物流数据
  401. * @apiSuccess {String} result.deliver_info.context 内容
  402. * @apiSuccess {String} result.deliver_info.time 时间
  403. */
  404. public function search_deliver()
  405. {
  406. $order_id = intval(input('post.order_id'));
  407. if ($order_id <= 0) {
  408. ds_json_encode(10001, lang('member_order_none_exist'));
  409. }
  410. $order_model = model('order');
  411. $condition[] = ['order_id', '=', $order_id];
  412. $condition[] = ['buyer_id', '=', $this->member_info['member_id']];
  413. $order_info = $order_model->getOrderInfo($condition, ['order_common', 'order_goods']);
  414. if (empty($order_info) || !in_array($order_info['order_state'], [ORDER_STATE_SEND, ORDER_STATE_SUCCESS])) {
  415. ds_json_encode(10001, lang('member_order_none_exist'));
  416. }
  417. $express = rkcache('express', true);
  418. if (isset($express[$order_info['extend_order_common']['shipping_express_id']])) {
  419. $express_code = $express[$order_info['extend_order_common']['shipping_express_id']]['express_code'];
  420. $express_name = $express[$order_info['extend_order_common']['shipping_express_id']]['express_name'];
  421. $deliver_info = $this->_get_express($express_code, $order_info['shipping_code'], $order_info['extend_order_common']['reciver_info']['phone']);
  422. } else {
  423. $express_name = '';
  424. $deliver_info = [];
  425. }
  426. ds_json_encode(10000, '', ['express_name' => $express_name, 'shipping_code' => $order_info['shipping_code'], 'deliver_info' => $deliver_info]);
  427. }
  428. /**
  429. * @api {POST} api/Memberorder/order_info 订单详情
  430. * @apiVersion 1.0.0
  431. * @apiGroup MemberOrder
  432. *
  433. * @apiHeader {String} X-DS-KEY 用户授权token
  434. *
  435. * @apiParam {Int} order_id 订单ID
  436. *
  437. * @apiSuccess {String} code 返回码,10000为成功
  438. * @apiSuccess {String} message 返回消息
  439. * @apiSuccess {Object} result 返回数据
  440. * @apiSuccess {Object} result.order_info 订单信息
  441. * @apiSuccess {Int} result.order_info.add_time 退款添加时间
  442. * @apiSuccess {String} result.order_info.buyer_email 买家邮箱
  443. * @apiSuccess {Int} result.order_info.buyer_id 买家ID
  444. * @apiSuccess {String} result.order_info.buyer_name 买家用户名
  445. * @apiSuccess {Int} result.order_info.delay_time 自动收货时间
  446. * @apiSuccess {Int} result.order_info.delete_state 订单删除状态 0:未删除 1:放入回收站 2:彻底删除
  447. * @apiSuccess {Int} result.order_info.evaluation_state 评论状态
  448. * @apiSuccess {Object} result.order_info.extend_order_common 订单公共信息
  449. * @apiSuccess {Int} result.order_info.extend_order_common.daddress_id 发货地址ID
  450. * @apiSuccess {String} result.order_info.extend_order_common.deliver_explain 订单发货备注
  451. * @apiSuccess {Int} result.order_info.extend_order_common.evalseller_state 卖家是否已评价买家
  452. * @apiSuccess {Int} result.order_info.extend_order_common.evalseller_time 卖家评价买家的时间
  453. * @apiSuccess {Int} result.order_info.extend_order_common.evaluation_time 评价时间
  454. * @apiSuccess {String} result.order_info.extend_order_common.invoice_info 订单发票信息
  455. * @apiSuccess {Int} result.order_info.extend_order_common.order_id 订单ID
  456. * @apiSuccess {String} result.order_info.extend_order_common.order_message 订单留言
  457. * @apiSuccess {Int} result.order_info.extend_order_common.order_pointscount 订单赠送积分
  458. * @apiSuccess {String} result.order_info.extend_order_common.promotion_info 订单促销信息备注
  459. * @apiSuccess {Int} result.order_info.extend_order_common.reciver_city_id 收货人市级ID
  460. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info 收货人其它信息
  461. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info.address 收货地址
  462. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info.area 收货地区
  463. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info.mob_phone 收货人手机号
  464. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info.phone 收货人联系号码
  465. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info.street 街道地址
  466. * @apiSuccess {String} result.order_info.extend_order_common.reciver_info.tel_phone 座机号
  467. * @apiSuccess {String} result.order_info.extend_order_common.reciver_name 收货人姓名
  468. * @apiSuccess {Int} result.order_info.extend_order_common.reciver_province_id 收货地区省ID
  469. * @apiSuccess {Int} result.order_info.extend_order_common.shipping_express_id 配送公司ID
  470. * @apiSuccess {Int} result.order_info.extend_order_common.shipping_time 发货时间
  471. * @apiSuccess {Int} result.order_info.extend_order_common.store_id 店铺ID
  472. * @apiSuccess {String} result.order_info.extend_order_common.voucher_code 代金券编码
  473. * @apiSuccess {Int} result.order_info.extend_order_common.voucher_price 代金券面额
  474. * @apiSuccess {Object} result.order_info.extend_store 店铺信息
  475. * @apiSuccess {String} result.order_info.extend_store.area_info 店铺地区
  476. * @apiSuccess {Int} result.order_info.extend_store.bind_all_gc 是否绑定所有分类 0否1是
  477. * @apiSuccess {String} result.order_info.extend_store.deliver_region 店铺默认配送区域
  478. * @apiSuccess {Int} result.order_info.extend_store.goods_count 商品数量
  479. * @apiSuccess {Int} result.order_info.extend_store.grade_id 等级ID
  480. * @apiSuccess {Int} result.order_info.extend_store.is_platform_store 是否自营店 0否1是
  481. * @apiSuccess {String} result.order_info.extend_store.mb_sliders 手机店铺轮播图序列化字符串
  482. * @apiSuccess {String} result.order_info.extend_store.mb_title_img 手机店铺背景图
  483. * @apiSuccess {Int} result.order_info.extend_store.member_id 店铺用户ID
  484. * @apiSuccess {String} result.order_info.extend_store.member_name 店铺用户名
  485. * @apiSuccess {Int} result.order_info.extend_store.region_id 店铺地区ID
  486. * @apiSuccess {String} result.order_info.extend_store.seller_name 卖家用户名
  487. * @apiSuccess {String} result.order_info.extend_store.store_address 店铺地址
  488. * @apiSuccess {Int} result.order_info.extend_store.store_addtime 店铺添加时间
  489. * @apiSuccess {Object[]} result.order_info.extend_store.store_aftersales 售后列表
  490. * @apiSuccess {String} result.order_info.extend_store.store_aftersales.name 售后名称
  491. * @apiSuccess {String} result.order_info.extend_store.store_aftersales.num 售后账号
  492. * @apiSuccess {String} result.order_info.extend_store.store_aftersales.type 售后类型 1QQ2旺旺3站内IM
  493. * @apiSuccess {Float} result.order_info.extend_store.store_avaliable_deposit 可用保证金
  494. * @apiSuccess {Float} result.order_info.extend_store.store_avaliable_money 可用预存款
  495. * @apiSuccess {String} result.order_info.extend_store.store_avatar 店铺头像
  496. * @apiSuccess {String} result.order_info.extend_store.store_banner 店铺背景图
  497. * @apiSuccess {Int} result.order_info.extend_store.store_baozh 是否已缴保证金 0否1是
  498. * @apiSuccess {Int} result.order_info.extend_store.store_bill_time 上次结算时间
  499. * @apiSuccess {String} result.order_info.extend_store.store_close_info 店铺关闭原因
  500. * @apiSuccess {Int} result.order_info.extend_store.store_collect 店铺收藏数量
  501. * @apiSuccess {String} result.order_info.extend_store.store_company_name 店铺公司名称
  502. * @apiSuccess {Object} result.order_info.extend_store.store_credit 店铺信用信息
  503. * @apiSuccess {String} result.order_info.extend_store.store_credit.store_deliverycredit 发货速度信息
  504. * @apiSuccess {Int} result.order_info.extend_store.store_credit.store_deliverycredit.credit 发货速度评分
  505. * @apiSuccess {String} result.order_info.extend_store.store_credit.store_deliverycredit.text 发货速度描述
  506. * @apiSuccess {Object} result.order_info.extend_store.store_credit.store_desccredit 描述相符信息
  507. * @apiSuccess {Int} result.order_info.extend_store.store_credit.store_desccredit.credit 描述相符评分
  508. * @apiSuccess {String} result.order_info.extend_store.store_credit.store_desccredit.text 描述相符描述
  509. * @apiSuccess {Object} result.order_info.extend_store.store_credit.store_servicecredit 服务态度信息
  510. * @apiSuccess {Int} result.order_info.extend_store.store_credit.store_servicecredit.credit 服务态度评分
  511. * @apiSuccess {String} result.order_info.extend_store.store_credit.store_servicecredit.text 服务态度描述
  512. * @apiSuccess {Int} result.order_info.extend_store.store_credit_average 平均评分
  513. * @apiSuccess {Int} result.order_info.extend_store.store_credit_percent 好评率
  514. * @apiSuccess {Int} result.order_info.extend_store.store_deliverycredit 发货速度评分
  515. * @apiSuccess {Int} result.order_info.extend_store.store_desccredit 描述相符评分
  516. * @apiSuccess {String} result.order_info.extend_store.store_description 店铺SEO描述
  517. * @apiSuccess {Int} result.order_info.extend_store.store_endtime 店铺到期时间
  518. * @apiSuccess {Int} result.order_info.extend_store.store_erxiaoshi 是否两小时发货 0否1是
  519. * @apiSuccess {Int} result.order_info.extend_store.store_free_price 超出该金额免运费 0未设置
  520. * @apiSuccess {Int} result.order_info.extend_store.store_free_time 商家配送时间
  521. * @apiSuccess {Float} result.order_info.extend_store.store_freeze_deposit 冻结保证金
  522. * @apiSuccess {Float} result.order_info.extend_store.store_freeze_money 冻结预存款
  523. * @apiSuccess {Int} result.order_info.extend_store.store_huodaofk 是否支持货到付款 0否1是
  524. * @apiSuccess {Int} result.order_info.extend_store.store_id 店铺ID
  525. * @apiSuccess {String} result.order_info.extend_store.store_keywords 店铺SEO关键字
  526. * @apiSuccess {String} result.order_info.extend_store.store_latitude 纬度
  527. * @apiSuccess {String} result.order_info.extend_store.store_logo 店铺logo
  528. * @apiSuccess {String} result.order_info.extend_store.store_longitude 经度
  529. * @apiSuccess {String} result.order_info.extend_store.store_mainbusiness 主营商品
  530. * @apiSuccess {String} result.order_info.extend_store.store_mgdiscount 序列化会员等级折扣
  531. * @apiSuccess {Int} result.order_info.extend_store.store_mgdiscount_state 店铺是否开启序列化会员等级折扣 0否1是
  532. * @apiSuccess {String} result.order_info.extend_store.store_name 店铺名称
  533. * @apiSuccess {Float} result.order_info.extend_store.store_payable_deposit 应缴保证金
  534. * @apiSuccess {String} result.order_info.extend_store.store_phone 店铺电话
  535. * @apiSuccess {Object[]} result.order_info.extend_store.store_presales 售前列表
  536. * @apiSuccess {String} result.order_info.extend_store.store_presales.name 售前名称
  537. * @apiSuccess {String} result.order_info.extend_store.store_presales.num 售前账号
  538. * @apiSuccess {String} result.order_info.extend_store.store_presales.type 售前类型 1QQ2旺旺3站内IM
  539. * @apiSuccess {String} result.order_info.extend_store.store_printexplain 打印订单页面下方说明文字
  540. * @apiSuccess {String} result.order_info.extend_store.store_qq 店铺QQ
  541. * @apiSuccess {Int} result.order_info.extend_store.store_qtian 是否支持7天退换 0否1是
  542. * @apiSuccess {Int} result.order_info.extend_store.store_recommend 推荐店铺 0否1是
  543. * @apiSuccess {Int} result.order_info.extend_store.store_sales 销量
  544. * @apiSuccess {Int} result.order_info.extend_store.store_servicecredit 服务态度评分
  545. * @apiSuccess {Int} result.order_info.extend_store.store_shiti 实体店认证 0否1是
  546. * @apiSuccess {Int} result.order_info.extend_store.store_shiyong 是否支持试用 0否1是
  547. * @apiSuccess {String} result.order_info.extend_store.store_slide 店铺幻灯片
  548. * @apiSuccess {String} result.order_info.extend_store.store_slide_url 店铺幻灯片链接
  549. * @apiSuccess {Int} result.order_info.extend_store.store_sort 店铺排序
  550. * @apiSuccess {Int} result.order_info.extend_store.store_state 店铺状态 0关闭,1开启,2审核中
  551. * @apiSuccess {Int} result.order_info.extend_store.store_tuihuo 是否支持退货承诺 0否1是
  552. * @apiSuccess {String} result.order_info.extend_store.store_vrcode_prefix 商家兑换码前缀
  553. * @apiSuccess {String} result.order_info.extend_store.store_workingtime 工作时间
  554. * @apiSuccess {String} result.order_info.extend_store.store_ww 店铺旺旺
  555. * @apiSuccess {Int} result.order_info.extend_store.store_xiaoxie 是否消协保证 0否1是
  556. * @apiSuccess {Int} result.order_info.extend_store.store_zhping 是否正品保障 0否1是
  557. * @apiSuccess {String} result.order_info.extend_store.store_zip 邮政编码
  558. * @apiSuccess {Int} result.order_info.extend_store.storeclass_id 店铺分类ID
  559. * @apiSuccess {Int} result.order_info.finnshed_time 订单完成时间
  560. * @apiSuccess {Float} result.order_info.goods_amount 商品总额
  561. * @apiSuccess {Int} result.order_info.goods_count 商品数量
  562. * @apiSuccess {Object[]} result.order_info.goods_list 商品列表
  563. * @apiSuccess {Int} result.order_info.goods_list.buyer_id 买家ID
  564. * @apiSuccess {Float} result.order_info.goods_list.commis_rate 佣金比例
  565. * @apiSuccess {Int} result.order_info.goods_list.gc_id 分类ID
  566. * @apiSuccess {Int} result.order_info.goods_list.goods_id 商品ID
  567. * @apiSuccess {String} result.order_info.goods_list.goods_image 商品图片
  568. * @apiSuccess {String} result.order_info.goods_list.goods_name 商品名称
  569. * @apiSuccess {Int} result.order_info.goods_list.goods_num 购买数量
  570. * @apiSuccess {Float} result.order_info.goods_list.goods_pay_price 实际支付金额
  571. * @apiSuccess {Float} result.order_info.goods_list.goods_price 商品金额
  572. * @apiSuccess {Int} result.order_info.goods_list.goods_type 商品类型 1默认2抢购商品3限时折扣商品4组合套装5赠品6拼团7会员等级折扣
  573. * @apiSuccess {Int} result.order_info.goods_list.order_id 订单ID
  574. * @apiSuccess {Int} result.order_info.goods_list.promotions_id 促销ID
  575. * @apiSuccess {Int} result.order_info.goods_list.rec_id 订单商品ID
  576. * @apiSuccess {Int} result.order_info.goods_list.store_id 店铺ID
  577. * @apiSuccess {Int} result.order_info.if_cancel 是否可取消 true是false否
  578. * @apiSuccess {Int} result.order_info.if_delete 是否可删除 true是false否
  579. * @apiSuccess {Int} result.order_info.if_deliver 是否显示物流跟踪 true是false否
  580. * @apiSuccess {Int} result.order_info.if_evaluation 是否可评价 true是false否
  581. * @apiSuccess {Int} result.order_info.if_lock 是否被锁定 true是false否
  582. * @apiSuccess {Int} result.order_info.if_receive 是否可收货 true是false否
  583. * @apiSuccess {Int} result.order_info.if_refund_cancel 是否可全部退款 true是false否
  584. * @apiSuccess {Int} result.order_info.lock_state 锁定状态:0:正常,大于0:锁定
  585. * @apiSuccess {Int} result.order_info.ob_no 结算单号
  586. * @apiSuccess {Float} result.order_info.order_amount 订单总金额
  587. * @apiSuccess {Int} result.order_info.order_from 订单来源,1:PC 2:手机
  588. * @apiSuccess {Int} result.order_info.order_id 订单ID
  589. * @apiSuccess {String} result.order_info.order_sn 订单编号
  590. * @apiSuccess {Int} result.order_info.order_state 订单状态
  591. * @apiSuccess {Int} result.order_info.order_type 订单类型
  592. * @apiSuccess {String} result.order_info.pay_sn 支付单号
  593. * @apiSuccess {String} result.order_info.payment_code 支付方式代码
  594. * @apiSuccess {String} result.order_info.payment_name 支付方式名称
  595. * @apiSuccess {Int} result.order_info.payment_time 支付时间
  596. * @apiSuccess {Float} result.order_info.pd_amount 使用预存款金额
  597. * @apiSuccess {object} result.order_info.promotion 促销信息
  598. * @apiSuccess {Float} result.order_info.rcb_amount 使用充值卡金额
  599. * @apiSuccess {String} result.order_info.real_pay_amount 实际支付金额
  600. * @apiSuccess {String} result.order_info.reciver_addr 收货地址
  601. * @apiSuccess {String} result.order_info.reciver_name 收货人姓名
  602. * @apiSuccess {String} result.order_info.reciver_phone 收货人手机
  603. * @apiSuccess {Float} result.order_info.refund_amount 退款金额
  604. * @apiSuccess {Int} result.order_info.refund_state 退款状态 0:无退款 1:部分退款 2:全部退款
  605. * @apiSuccess {String} result.order_info.shipping_code 发货运单号
  606. * @apiSuccess {Float} result.order_info.shipping_fee 运费
  607. * @apiSuccess {String} result.order_info.state_desc 状态描述
  608. * @apiSuccess {Int} result.order_info.store_id 店铺ID
  609. * @apiSuccess {Int} result.order_info.store_member_id 店铺用户ID
  610. * @apiSuccess {String} result.order_info.store_name 店铺名称
  611. * @apiSuccess {String} result.order_info.store_phone 店铺电话
  612. * @apiSuccess {object} result.order_info.zengpin_list 赠品列表
  613. */
  614. public function order_info()
  615. {
  616. $order_id = intval(input('order_id'));
  617. if ($order_id <= 0) {
  618. ds_json_encode(10001, lang('member_order_none_exist'));
  619. }
  620. $order_model = model('order');
  621. $condition = [];
  622. $condition[] = ['order_id', '=', $order_id];
  623. $condition[] = ['buyer_id', '=', $this->member_info['member_id']];
  624. $order_info = $order_model->getOrderInfo($condition, ['order_goods', 'order_common', 'store']);
  625. if (empty($order_info) || $order_info['delete_state'] == ORDER_DEL_STATE_DROP) {
  626. ds_json_encode(10001, lang('member_order_none_exist'));
  627. }
  628. $refundreturn_model = model('refundreturn');
  629. $order_list = [];
  630. $order_list[$order_id] = $order_info;
  631. $order_list = $refundreturn_model->getGoodsRefundList($order_list, 1); //订单商品的退款退货显示
  632. $order_info = $order_list[$order_id];
  633. $refund_all = isset($order_info['refund_list'][0]) ? $order_info['refund_list'][0] : '';
  634. if (!empty($refund_all) && $refund_all['seller_state'] < 3) {//订单全部退款商家审核状态:1为待审核,2为同意,3为不同意
  635. $result['refund_all'] = $refund_all;
  636. }
  637. $order_info['store_member_id'] = $order_info['extend_store']['member_id'];
  638. $order_info['store_phone'] = $order_info['extend_store']['store_phone'];
  639. //显示系统自动取消订单日期
  640. if ($order_info['order_state'] == ORDER_STATE_NEW || $order_info['order_state'] == ORDER_STATE_DEPOSIT) {
  641. $order_info['order_cancel_day'] = $order_info['add_time'] + config('ds_config.order_auto_cancel_day') * 24 * 3600;
  642. } else if ($order_info['order_state'] == ORDER_STATE_REST) {
  643. $order_info['order_cancel_day'] = $order_info['presell_end_time'] + 72 * 3600;
  644. }
  645. if ($order_info['extend_order_common']['order_message']) {
  646. $order_info['order_message'] = $order_info['extend_order_common']['order_message'];
  647. }
  648. if (!empty($order_info['extend_order_common']['invoice_info'])) {
  649. $order_info['invoice'] = $order_info['extend_order_common']['invoice_info']['类型'] . $order_info['extend_order_common']['invoice_info']['抬头'] . $order_info['extend_order_common']['invoice_info']['内容'];
  650. }
  651. $order_info['reciver_phone'] = $order_info['extend_order_common']['reciver_info']['phone'];
  652. $order_info['reciver_name'] = $order_info['extend_order_common']['reciver_name'];
  653. $order_info['reciver_addr'] = $order_info['extend_order_common']['reciver_info']['address'];
  654. $order_info['promotion'] = [];
  655. //显示锁定中
  656. $order_info['if_lock'] = $order_model->getOrderOperateState('lock', $order_info);
  657. //显示取消订单
  658. $order_info['if_buyer_cancel'] = $order_model->getOrderOperateState('buyer_cancel', $order_info);
  659. //显示退款取消订单
  660. $order_info['if_refund_cancel'] = $order_model->getOrderOperateState('refund_cancel', $order_info);
  661. //显示投诉
  662. $order_info['if_complain'] = $order_model->getOrderOperateState('complain', $order_info);
  663. //显示收货
  664. $order_info['if_receive'] = $order_model->getOrderOperateState('receive', $order_info);
  665. //显示物流跟踪
  666. $order_info['if_deliver'] = $order_model->getOrderOperateState('deliver', $order_info);
  667. //显示评价
  668. $order_info['if_evaluation'] = $order_model->getOrderOperateState('evaluation', $order_info);
  669. //因为格式化了时间导致按钮判断错误
  670. if ($order_info['payment_time']) {
  671. $order_info['payment_time'] = date('Y-m-d H:i:s', $order_info['payment_time']);
  672. } else {
  673. $order_info['payment_time'] = '';
  674. }
  675. if ($order_info['finnshed_time']) {
  676. $order_info['finnshed_time'] = date('Y-m-d H:i:s', $order_info['finnshed_time']);
  677. } else {
  678. $order_info['finnshed_time'] = '';
  679. }
  680. if ($order_info['add_time']) {
  681. $order_info['add_time'] = date('Y-m-d H:i:s', $order_info['add_time']);
  682. } else {
  683. $order_info['add_time'] = '';
  684. }
  685. $order_info['if_deliver'] = false;
  686. //显示快递信息
  687. if ($order_info['shipping_code'] != '') {
  688. $order_info['if_deliver'] = true;
  689. $express = rkcache('express', true);
  690. if (isset($express[$order_info['extend_order_common']['shipping_express_id']])) {
  691. $order_info['express_info']['express_code'] = $express[$order_info['extend_order_common']['shipping_express_id']]['express_code'];
  692. $order_info['express_info']['express_name'] = $express[$order_info['extend_order_common']['shipping_express_id']]['express_name'];
  693. $order_info['express_info']['express_url'] = $express[$order_info['extend_order_common']['shipping_express_id']]['express_url'];
  694. } else {
  695. $order_info['express_info']['express_code'] = '';
  696. $order_info['express_info']['express_name'] = '';
  697. $order_info['express_info']['express_url'] = '';
  698. }
  699. }
  700. //显示系统自动收获时间
  701. if ($order_info['order_state'] == ORDER_STATE_SEND) {
  702. $order_info['order_confirm_day'] = $order_info['delay_time'] + config('ds_config.order_auto_receive_day') * 24 * 3600;
  703. }
  704. //如果订单已取消,取得取消原因、时间,操作人
  705. if ($order_info['order_state'] == ORDER_STATE_CANCEL) {
  706. $close_info = $order_model->getOrderlogInfo(['order_id' => $order_info['order_id']], 'log_id desc');
  707. $order_info['close_info'] = $close_info;
  708. // $order_info['state_desc'] = $close_info['log_orderstate'];
  709. $order_info['order_tips'] = $close_info['log_msg'];
  710. }
  711. $order_info['chain_order_type'] = 0;
  712. //如果是待自提则获取提货码
  713. $chain_order_model = model('chain_order');
  714. $chain_order_info = $chain_order_model->getChainOrderInfo([['order_id', '=', $order_info['order_id']]]);
  715. if ($chain_order_info) {
  716. $order_info['chain_order_type'] = $chain_order_info['chain_order_type'];
  717. $order_info['chain_order_pickup_code'] = $chain_order_info['chain_order_pickup_code'];
  718. $chain_model = model('chain');
  719. $chain_info = $chain_model->getChainInfo([['chain_id', '=', $chain_order_info['chain_id']]]);
  720. if ($chain_info) {
  721. $order_info['chain_addressname'] = $chain_info['chain_addressname'];
  722. $order_info['chain_address'] = $chain_info['chain_address'];
  723. $phone_list = [];
  724. if ($chain_info['chain_mobile']) {
  725. $phone_list[] = $chain_info['chain_mobile'];
  726. }
  727. if ($chain_info['chain_telephony']) {
  728. $phone_list[] = $chain_info['chain_telephony'];
  729. }
  730. $order_info['chain_phone'] = implode(',', $phone_list);
  731. }
  732. }
  733. foreach ($order_info['extend_order_goods'] as $value) {
  734. $value['image_240_url'] = goods_cthumb($value['goods_image'], 240, $value['store_id']);
  735. $value['image_url'] = goods_cthumb($value['goods_image'], 240, $value['store_id']);
  736. $value['goods_type_cn'] = get_order_goodstype($value['goods_type']);
  737. if ($value['goods_type'] == 5) {
  738. $order_info['zengpin_list'][] = $value;
  739. } else {
  740. $order_info['goods_list'][] = $value;
  741. }
  742. }
  743. if (empty($order_info['zengpin_list'])) {
  744. $order_info['goods_count'] = count($order_info['goods_list']);
  745. } else {
  746. $order_info['goods_count'] = count($order_info['goods_list']) + 1;
  747. }
  748. $order_info['real_pay_amount'] = $order_info['order_amount'] + $order_info['shipping_fee'];
  749. //取得其它订单类型的信息000--------------------------------
  750. //$order_model->getOrderExtendInfo($order_info);
  751. $result['order_info'] = $order_info;
  752. ds_json_encode(10000, '', $result);
  753. }
  754. /**
  755. * 订单详情
  756. */
  757. public function get_current_deliver()
  758. {
  759. $order_id = intval(input('post.order_id'));
  760. if ($order_id <= 0) {
  761. ds_json_encode(10001, lang('member_order_none_exist'));
  762. }
  763. $order_model = model('order');
  764. $condition = [];
  765. $condition[] = ['order_id', '=', $order_id];
  766. $condition[] = ['buyer_id', '=', $this->member_info['member_id']];
  767. $order_info = $order_model->getOrderInfo($condition, ['order_common', 'order_goods']);
  768. if (empty($order_info) || !in_array($order_info['order_state'], [ORDER_STATE_SEND, ORDER_STATE_SUCCESS])) {
  769. ds_json_encode(10001, lang('member_order_none_exist'));
  770. }
  771. $express = rkcache('express', true);
  772. if (!empty($order_info['extend_order_common']['shipping_express_id'])) {
  773. $express_code = $express[$order_info['extend_order_common']['shipping_express_id']]['express_code'];
  774. $express_name = $express[$order_info['extend_order_common']['shipping_express_id']]['express_name'];
  775. } else {
  776. $express_code = '';
  777. $express_name = '';
  778. }
  779. $deliver_info = $this->_get_express($express_code, $order_info['shipping_code'], $order_info['extend_order_common']['reciver_info']['phone']);
  780. $data = [];
  781. $data['deliver_info']['context'] = $express_name;
  782. $data['deliver_info']['time'] = $deliver_info['0'];
  783. ds_json_encode(10000, '', $data);
  784. }
  785. /**
  786. * 从第三方取快递信息
  787. *
  788. */
  789. public function _get_express($express_code, $shipping_code, $phone)
  790. {
  791. $result = model('express')->queryExpress($express_code, $shipping_code, $phone);
  792. if ($result['Success'] != true) {
  793. ds_json_encode(10001, lang('deliver_search_fail'));
  794. }
  795. $content['Traces'] = array_reverse($result['Traces']);
  796. $output = [];
  797. if (is_array($content['Traces'])) {
  798. foreach ($content['Traces'] as $k => $v) {
  799. if ($v['AcceptTime'] == '')
  800. continue;
  801. //$output[] = $v['time'] . '&nbsp;&nbsp;' . $v['context'];
  802. $output[$k]['AcceptTime'] = $v['AcceptTime'];
  803. $output[$k]['AcceptStation'] = $v['AcceptStation'];
  804. }
  805. }
  806. if (empty($output))
  807. ds_json_encode(10001, lang('deliver_not_support'));
  808. return $output;
  809. }
  810. }
  811. ?>