123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- namespace app\data\controller\api;
- use app\data\model\ShopGoodsCart;
- use app\data\model\ShopGoods;
- use app\data\model\ShopGoodsItem;
- use app\data\model\ShopOrder;
- use app\data\model\ShopOrderItem;
- use app\data\service\OrderService;
- use think\admin\Controller;
- use hg\apidoc\annotation\Title;
- use hg\apidoc\annotation\Method;
- use hg\apidoc\annotation\Param;
- use hg\apidoc\annotation\Returned;
- /**
- * 商品订单接口
- * Class Order
- * @package app\data\controller\api
- */
- class Order extends Auth
- {
- /**
- * @Title("商品规格下单")
- * @Method("post")
- * @Param("admin_id",desc="商家id")
- * @Param("item_id",desc="规格id")
- * @Param("num",desc="数量")
- * @Param ("address_id",desc="地址id")
- */
- public function order_create(){
- $user = $this->getUser();
- $item_id =input('item_id');
- $address_id=input('address_id');
- $number = input('number');
- $data=[
- 'uuid'=>$user['id'],
- 'address_id'=>$address_id,
- 'item_id'=>$item_id,
- 'number'=>$number,
- ];
- $shop_order_model = new ShopOrder();
- $pay_on = $shop_order_model->order_create($data);
- $this->success('快去支付吧',$pay_on);
- }
- /**
- * @Title("购物车下单")
- * @Method("post")
- * @Param("cart_ids",desc="购物车id(数组)")
- * @Param ("address_id",desc="地址id")
- */
- public function crat_create(){
- $user =$this->getUser();
- $cart_ids = input('cart_ids');
- // $cart_ids=array(1,2);
- $address_id = input('address_id');
- $data=[
- 'uuid'=>$user['id'],
- 'cart_ids'=>$cart_ids,
- 'address_id'=>$address_id,
- ];
- $shop_order_model = new ShopOrder();
- $pay_on = $shop_order_model->cart_create($data);
- $this->success('快去支付吧',$pay_on);
- }
- /**
- * @Title("我的订单")
- * @Method("post")
- * @Param("order_name",desc="搜索名称")
- * @Param ("status",desc="1全部 2 待支付 3代发货 4 待收货 5退款/已退款")
- */
- public function order_list(){
- $user = $this->getUser();
- $status = input('status',1);
- if(!empty($status)){
- switch ($status){
- case 1:
- $array = [0,1,2,3,4,5,6,7];
- break;
- case 2:
- $array = [2];
- break;
- case 3:
- $array = [4];
- break;
- case 4:
- $array = [5];
- break;
- case 5:
- $array = [6,7];
- break;
- }
- }
- $query = ShopOrder::mQuery()->like('order_name');
- $list = $query ->where('uuid',$user['id'])
- ->whereIn('status',$array)->order('id desc')->page(true, false, false, 10);
- foreach ($list['list'] as $k=>$v){
- $list['list'][$k]['goods_item']=ShopOrderItem::mk()->where('order_no',$list['list'][$k]['order_no'])->select();
- }
- $this->success('我的订单列表',$list);
- }
- /**
- * @Title ("申请退款")
- * @Method ("post")
- * @Param ("order_id",desc="订单id")
- * @Param ("reason",desc="退款原因")
- * @Param("desc",desc="描述
- * ")
- */
- public function refund(){
- $user = $this->getUser();
- $order_id = input('order_id');
- $refund_money = ShopOrder::mk()->where(array('uuid'=>$user['id'],'order_id'=>$order_id))->value('payment_amount');
- $refund_reason = input('reason');
- if(empty($refund_reason)){
- $this->error('退款原因不能为空');
- }
- $refund_desc = input('desc');
- ShopOrder::mk()->where(array('uuid'=>$user['id'],'order_id'=>$order_id))->save(['refund_money'=>$refund_money,'refund_reason'=>$refund_reason,'refund_desc'=>$refund_desc,'status'=>6]);
- $this->success('退款已提交');
- }
- }
|