123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- <?php
- namespace app\api\controller\shop;
- use app\admin\model\Pingjia;
- use app\api\controller\Base;
- use app\api\model\User;
- /**
- * 商城订单
- * @ApiWeigh (10)
- * @package app\api\controller\shop
- */
- class Order extends Base
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['*'];
- /**
- * 订单列表
- * @ApiMethod (GET)
- * @ApiParams (name=type,type="string", required=true, description="all=全部订单,nopay=待付款,nosend=待发货,noget=待收货,nocomment=待评价,aftersale=退款/售后,invalid=交易关闭,cancel取消订单")
- * @ApiParams (name=page,type="int", required=false, description="页数")
- * @ApiReturnParams (name="id", type="int", required=true, description="order_id订单id")
- * @ApiReturnParams (name="order_sn", type="string", required=true, description="订单编号")
- * @ApiReturnParams (name="goods_amount", type="string", required=true, description="商品总价")
- * @ApiReturnParams (name="dispatch_amount", type="string", required=true, description="总运费")
- * @ApiReturnParams (name="phone", type="string", required=true, description="收件人电话")
- * @ApiReturnParams (name="consignee", type="string", required=true, description="收件人姓名")
- * @ApiReturnParams (name="province_name", type="string", required=true, description="省")
- * @ApiReturnParams (name="city_name", type="string", required=true, description="市")
- * @ApiReturnParams (name="area_name", type="string", required=true, description="区")
- * @ApiReturnParams (name="address", type="string", required=true, description="详细地址")
- * @ApiReturnParams (name="province_id", type="int", required=true, description="省id")
- * @ApiReturnParams (name="city_id", type="int", required=true, description="市id")
- * @ApiReturnParams (name="area_id", type="int", required=true, description="区id")
- * @ApiReturnParams (name="status", type="int", required=true, description="订单状态:-2=交易关闭,-1=已取消,0=未支付,1=已支付,2=已完成")
- * @ApiReturnParams (name="remark", type="string", required=true, description="用户备注")
- * @ApiReturnParams (name="total_amount", type="string", required=true, description="订单总金额")
- * @ApiReturnParams (name="score_amount", type="int", required=true, description="积分总数")
- * @ApiReturnParams (name="total_fee", type="string", required=true, description="支付金额")
- * @ApiReturnParams (name="item", type="array", required=true, description="订单商品明细")
- * @ApiReturnParams (name="item.id", type="int", required=true, description="订单商品明细id")
- * @ApiReturnParams (name="item.goods_id", type="int", required=true, description="商品id")
- * @ApiReturnParams (name="item.goods_sku_price_id", type="int", required=true, description="规格 id")
- * @ApiReturnParams (name="item.goods_title", type="int", required=true, description="商品名称")
- * @ApiReturnParams (name="item.goods_image", type="int", required=true, description="商品图片")
- * @ApiReturnParams (name="item.goods_num", type="int", required=true, description="商品数量")
- * @ApiReturn ({"code":1,"msg":"订单列表","time":"1672996645","data":{"total":1,"per_page":10,"current_page":1,"last_page":1,"data":[{"id":141,"type":"goods","order_sn":"202305575966329839003000","user_id":3,"activity_type":"","goods_amount":"199.98","dispatch_amount":"0.00","phone":"13161001120","consignee":"线下活动","province_name":"北京","city_name":"北京市","area_name":"东城区","address":"地址","province_id":1,"city_id":2,"area_id":3,"status":0,"invoice_status":"0","memo":null,"remark":null,"total_amount":"199.98","score_amount":0,"total_fee":"199.98","last_total_fee":"0.00","discount_fee":"0.00","coupon_fee":"0.00","activity_discount_money":"0.00","dispatch_discount_money":"0.00","pay_fee":"0.00","score_fee":0,"goods_original_amount":"258.00","coupons_id":0,"transaction_id":null,"payment_json":null,"pay_type":null,"paytime":null,"ext":"{\"buy_type\":\"alone\",\"groupon_id\":0,\"expired_time\":1672827180}","platform":null,"createtime":1672826280,"item":[{"id":144,"user_id":3,"order_id":141,"goods_id":44,"goods_type":"normal","goods_sku_price_id":128,"activity_id":0,"activity_type":null,"item_goods_sku_price_id":0,"goods_sku_text":null,"goods_title":"鱼竿套装","goods_image":"http://localhost:8005/uploads/20230103/f6545a5b3f3b8beff8ee04027fbf2c79.png","goods_original_price":"129.00","discount_fee":"0.00","goods_price":"99.99","goods_num":2,"goods_weight":0,"pay_price":"199.98","dispatch_status":0,"dispatch_fee":"0.00","dispatch_type":"express","dispatch_id":1,"store_id":0,"aftersale_status":0,"comment_status":0,"refund_status":0,"refund_fee":null,"refund_msg":null,"express_name":null,"express_code":null,"express_no":null,"ext":"[]","createtime":1672826280,"updatetime":1672826280,"status_code":"nopay","status_name":"","status_desc":"","btns":[],"ext_arr":[],"status_text":""}],"status_code":"nopay","status_name":"待付款","status_desc":"等待买家付款","btns":["cancel","pay"],"ext_arr":{"buy_type":"alone","groupon_id":0,"expired_time":1672827180}}]}})
- */
- public function index()
- {
- $params = $this->request->post();
- $this->success('订单列表', \app\api\model\order\Order::getList($params));
- }
- public function item_list(){
- $params = $this->request->post();
- $this->success('订单列表', \app\api\model\order\Order::getItemList($params));
- }
- /**
- * 订单详情
- * @ApiMethod (GET)
- * @ApiParams (name=id,type="int", required=true, description="订单id")
- * @ApiReturnParams (name="express_name", type="int", required=true, description="快递公司")
- * @ApiReturnParams (name="express_code", type="int", required=true, description="快递编号")
- * @ApiReturnParams (name="express_no", type="int", required=true, description="快递单号")
- * @ApiReturnParams (name="pay_type", type="string", required=true, description="支付方式:wechat=微信支付,alipay=支付宝,wallet=钱包支付,score=积分支付")
- * @ApiReturnParams (name="createtime", type="int", required=true, description="创建时间")
- * @ApiReturnParams (name="paytime", type="int", required=true, description="支付时间")
- * @ApiReturnParams (name="createtime", type="int", required=true, description="创建时间")
- * @ApiReturnParams (name="item.ext_arr.send_time", type="int", required=true, description="发货时间")
- * @ApiReturnParams (name="item.ext_arr.expired_time", type="int", required=true, description="待付款时间倒计时")
- * @ApiReturnParams (name="item.ext_arr.confirm_time", type="int", required=true, description="确认收货时间")
- * @ApiReturnParams (name="item.ext_arr.comment_time", type="int", required=true, description="评论时间")
- * @ApiReturnParams (name="item.ext_arr.aftersale_id", type="int", required=true, description="售后订单id")
- * @ApiReturnParams (name="item.ext_arr.aftersale_id", type="int", required=true, description="售后订单id")
- * @ApiReturn ({"code":1,"msg":"订单详情","time":"1672999087","data":{"id":155,"type":"goods","order_sn":"202305481871407611003000","user_id":3,"activity_type":"","goods_amount":"3.00","dispatch_amount":"0.00","phone":"13161001120","consignee":"线下","province_name":"北京","city_name":"北京市","area_name":"东城区","address":"地址","province_id":1,"city_id":2,"area_id":3,"status":1,"invoice_status":"0","memo":null,"remark":"remark","total_amount":"3.00","score_amount":200,"total_fee":"1.00","last_total_fee":"0.00","discount_fee":"0.00","coupon_fee":"0.00","activity_discount_money":"0.00","dispatch_discount_money":"0.00","pay_fee":"1.00","score_fee":200,"goods_original_amount":"240.00","coupons_id":0,"transaction_id":"","payment_json":"{\"order_sn\":\"202305481871407611003000\",\"transaction_id\":\"\",\"notify_time\":\"2023-01-05 17:49:33\",\"buyer_email\":3,\"pay_fee\":\"1.00\",\"pay_type\":\"wallet\"}","pay_type":"wallet","paytime":1672912173,"ext":"{\"buy_type\":\"alone\",\"groupon_id\":0,\"expired_time\":1672913001,\"send_time\":1672976628,\"confirm_time\":1672987755,\"comment_time\":1672989478}","platform":null,"createtime":1672912099,"item":[{"id":160,"user_id":3,"order_id":155,"goods_id":45,"goods_type":"normal","goods_sku_price_id":129,"activity_id":0,"activity_type":null,"item_goods_sku_price_id":0,"goods_sku_text":"红色,木质","goods_title":"鱼竿多规格","goods_image":"http://localhost:8005/assets/img/qrcode.png","goods_original_price":"120.00","discount_fee":"0.00","goods_price":"1.00","goods_num":1,"goods_weight":0,"pay_price":"1.00","dispatch_status":2,"dispatch_fee":"0.00","dispatch_type":"express","dispatch_id":1,"store_id":0,"aftersale_status":2,"comment_status":1,"refund_status":0,"refund_fee":null,"refund_msg":null,"express_name":"邮政快递包裹","express_code":"YZPY","express_no":"9889857225184","ext":"{\"send_time\":1672976475,\"confirm_time\":1672987754,\"aftersale_id\":\"1\"}","createtime":1672912100,"updatetime":1672993501,"status_code":"after_finish|commented","status_name":"售后完成","status_desc":"售后完成","btns":["buy_again","aftersale_info"],"ext_arr":{"send_time":1672976475,"confirm_time":1672987754,"aftersale_id":"1"}},{"id":161,"user_id":3,"order_id":155,"goods_id":45,"goods_type":"normal","goods_sku_price_id":130,"activity_id":0,"activity_type":null,"item_goods_sku_price_id":0,"goods_sku_text":"黑色,木质","goods_title":"鱼竿多规格","goods_image":"http://localhost:8005/assets/img/qrcode.png","goods_original_price":"120.00","discount_fee":"0.00","goods_price":"2.00","goods_num":1,"goods_weight":0,"pay_price":"2.00","dispatch_status":1,"dispatch_fee":"0.00","dispatch_type":"express","dispatch_id":1,"store_id":0,"aftersale_status":0,"comment_status":0,"refund_status":0,"refund_fee":null,"refund_msg":null,"express_name":"邮政快递包裹","express_code":"YZPY","express_no":"9889857225184","ext":"{\"send_time\":1672976628}","createtime":1672912100,"updatetime":1672976628,"status_code":"noget","status_name":"待收货","status_desc":"等待买家收货","btns":["get","aftersale"],"ext_arr":{"send_time":1672976628}}],"status_code":"commented","status_name":"已评价","status_desc":"订单已评价","btns":["express"],"ext_arr":{"buy_type":"alone","groupon_id":0,"expired_time":1672913001,"send_time":1672976628,"confirm_time":1672987755,"comment_time":1672989478}}})
- */
- public function detail()
- {
- $params = $this->request->get();
- $this->success('订单详情', \app\api\model\order\Order::detail($params));
- }
- /**
- * @ApiInternal
- */
- public function itemDetail()
- {
- $params = $this->request->get();
- $this->success('订单商品', \addons\shopro\model\Order::itemDetail($params));
- }
- // 即将废弃
- /**
- * @ApiInternal
- */
- public function statusNum()
- {
- $this->success('订单数量', \addons\shopro\model\Order::statusNum());
- }
- /**
- * @ApiInternal
- * 取消订单
- */
- public function cancel()
- {
- $params = $this->request->post();
- // 表单验证
- $this->shoproValidate($params, get_class(), 'cancel');
- $this->success('取消成功', \addons\shopro\model\Order::operCancel($params));
- }
- /**
- * @ApiInternal
- * 删除订单
- */
- public function delete()
- {
- $params = $this->request->post();
- // 表单验证
- $this->shoproValidate($params, get_class(), 'delete');
- $this->success('删除成功', \app\api\model\order\Order::operDelete($params));
- }
- /**
- * 确认收货
- * @ApiMethod (POST)
- * @ApiParams (name=id,type="int", required=true, description="订单id")
- * @ApiParams (name=order_item_id,type="int", required=true, description="订单商品明细的id")
- */
- public function confirm()
- {
- $params = $this->request->post();
- // 表单验证
- $this->shoproValidate($params, get_class(), 'confirm');
- $this->success('收货成功', \app\api\model\order\Order::operConfirm($params));
- }
- /**
- * 提交评论
- * @ApiMethod (POST)
- * @ApiParams (name=id,type="int", required=true, description="订单id")
- * @ApiParams (name=order_item_id,type="int", required=true, description="订单商品明细的id")
- * @ApiParams (name=level,type="int", required=true, description="评价星级")
- * @ApiParams (name=content,type="string", required=true, description="评论内容")
- * @ApiParams (name=images,type="string", required=true, description="图片:中文,分割")
- */
- public function comment()
- {
- $params = $this->request->post();
- if (!isset($params['list']) || empty($params['list'])) {
- $this->error('参数错误');
- }
- // 表单验证
- // $this->shoproValidate($params, get_class(), 'comment');
- foreach ($params['list'] as $v) {
- \app\api\model\order\Order::operComment($v);
- }
- $this->success('评价成功');
- }
- /**
- * 确认订单
- * @ApiMethod (POST)
- * @ApiParams (name=goods_list,type="array", required=true, description="商品列表")
- * @ApiParams (name=goods_list.goods_id,type="int", required=true, description="商品id")
- * @ApiParams (name=goods_list.sku_price_id,type="int", required=true, description="商品规格id")
- * @ApiParams (name=goods_list.goods_num,type="int", required=true, description="商品数量")
- * @ApiParams (name=address_id,type="int", required=true, description="地址id,计算运费")
- * @ApiParams (name=from,type="string", required=true, description="来源:cart=购物车,“”=其他")
- * @ApiReturn ({"code":1,"msg":"计算成功","time":"1672903281","data":{"goods_original_amount":"149.00","goods_amount":"125.00","origin_dispatch_amount":"3.00","dispatch_amount":"3.00","total_amount":"128.00","total_fee":"128.00","discount_fee":"0.00","coupon_fee":"0.00","activity_discount_money":"0.00","dispatch_discount_money":"0.00","invoice_amount":"125.00","activity_type":"","score_amount":0,"new_goods_list":[{"goods_id":"46","sku_price_id":"133","goods_num":1,"dispatch_type":"express","detail":{"id":46,"type":"normal","title":"精品鱼竿","subtitle":"精品鱼竿12345648787","weigh":0,"category_ids":"166","image":"http://localhost:8005/uploads/20230103/f6545a5b3f3b8beff8ee04027fbf2c79.png","images":["http://localhost:8005/uploads/20230103/f6545a5b3f3b8beff8ee04027fbf2c79.png","http://localhost:8005/uploads/20230103/5aa40166ccf7b3e9d3dbeb1a01285607.png"],"params":[{"title":"发货地","content":"临沂"}],"content":"<p>1456</p>","price":"125","original_price":"149.00","is_sku":0,"likes":0,"views":2,"sales":0,"show_sales":0,"service_ids":"1","dispatch_type":"express","dispatch_ids":"4","deletetime":null,"current_sku_price":{"id":133,"goods_sku_ids":null,"goods_id":46,"weigh":0,"image":null,"stock":100,"stock_warning":null,"sales":0,"sn":"","weight":0,"price":"125.00","goods_sku_text":null,"status":"up","goods_sku_id_arr":[""]},"favorite":null,"sku_price":[{"id":133,"goods_sku_ids":null,"goods_id":46,"weigh":0,"image":null,"stock":100,"stock_warning":null,"sales":0,"sn":"","weight":0,"price":"125.00","goods_sku_text":null,"status":"up","goods_sku_id_arr":[""]}],"dispatch_type_arr":["express"],"service":[{"id":1,"name":"正品保障","image":"http://file.shopro.top/uploads/20210524/8ca30cc57e2f0f9bea5b32c0d7a2a9fe.png","description":"正品保障,假一赔三"}],"sku":[]},"goods_original_amount":"149.00","goods_amount":"125.00","dispatch_amount":"3.00","score_amount":0,"dispatch_id":4,"store_id":0,"activity_type":"","discount_fee":"0.00","pay_price":"125.00"}],"need_address":1,"activity_discount_infos":[],"user_score":600,"msg":null}})
- */
- public function pre()
- {
- $params = $this->request->post();
- // 表单验证
- $this->shoproValidate($params, get_class(), 'pre');
- $result = \app\api\model\order\OrderOper::pre($params);
- if (isset($result['msg']) && $result['msg']) {
- $this->error($result['msg'], $result);
- } else {
- $this->success('计算成功', $result);
- }
- }
- /**
- * 提交订单
- * @ApiMethod (POST)
- * @ApiParams (name=goods_list,type="array", required=true, description="商品列表")
- * @ApiParams (name=goods_list.goods_id,type="int", required=true, description="商品id")
- * @ApiParams (name=goods_list.sku_price_id,type="int", required=true, description="商品规格id")
- * @ApiParams (name=goods_list.goods_num,type="int", required=true, description="商品数量")
- * @ApiParams (name=address_id,type="int", required=true, description="地址id,计算运费")
- * @ApiParams (name=cart_id,type="array", description="购物车id,以数组传递")
- * @ApiParams (name=from,type="string", required=true, description="来源:cart=购物车,“”=其他")
- * @ApiParams (name=use_score,type="int", required=true, description="使用积分")
- * @ApiParams (name=remark,type="string", required=true, description="备注")
- * @ApiReturn ({"code":1,"msg":"订单添加成功","time":"1672903265","data":{"id":154,"type":"goods","order_sn":"202303210790748951003000","user_id":3,"activity_type":"","goods_amount":"3.00","dispatch_amount":"0.00","phone":"13161001120","consignee":"线下活动","province_name":"北京","city_name":"北京市","area_name":"东城区","address":"地址","province_id":1,"city_id":2,"area_id":3,"status":0,"invoice_status":"0","memo":null,"remark":"remark","total_amount":"3.00","score_amount":200,"total_fee":"1.00","last_total_fee":"0.00","discount_fee":"0.00","coupon_fee":"0.00","activity_discount_money":"0.00","dispatch_discount_money":"0.00","pay_fee":"0.00","score_fee":200,"goods_original_amount":"240.00","coupons_id":0,"transaction_id":null,"payment_json":null,"pay_type":null,"paytime":null,"ext":"{\"buy_type\":\"alone\",\"groupon_id\":0,\"expired_time\":1672904169}","platform":null,"createtime":1672903268,"status_code":"nopay","status_name":"待付款","status_desc":"等待买家付款","btns":["cancel","pay"],"ext_arr":{"buy_type":"alone","groupon_id":0,"expired_time":1672904169}}})
- */
- public function createOrder()
- {
- $params = $this->request->post();
- // 表单验证
- $this->shoproValidate($params, get_class(), 'createOrder');
- $order = \app\api\model\order\OrderOper::createOrder($params);
- $this->success('订单添加成功', $order);
- }
- public function cancelOrder()
- {
- $params = $this->request->post();
- extract($params);
- if(!isset($id)) {
- $this->error('未知的鱼塘id');
- }
- if (!is_array($id)) {
- $id = [$id];
- }
- foreach ($id as $value) {
- $order = (new \app\admin\model\Order())->where('id', $value)->find();
- $order->save(['status' => 4]);
- }
- $this->success('修改成功');
- }
- // 获取可用优惠券列表
- // public function coupons()
- // {
- // $params = $this->request->post();
- //
- // // 表单验证
- // $this->shoproValidate($params, get_class(), 'coupons');
- //
- // $coupons = \addons\shopro\model\Order::coupons($params);
- //
- // $this->success('获取成功', $coupons);
- // }
- }
|