|
@@ -1,5 +1,6 @@
|
|
|
<?php
|
|
|
namespace app\api\controller;
|
|
|
+use app\common\model\BillApply;
|
|
|
use app\common\model\OrderComment;
|
|
|
use app\common\model\OrderLogisticsUrge;
|
|
|
use app\common\model\ShoppingTrolley;
|
|
@@ -11,6 +12,7 @@ use app\common\model\GoodsOrderItem;
|
|
|
use app\common\model\User;
|
|
|
use app\common\model\UserMessage;
|
|
|
use app\common\service\ExpressService;
|
|
|
+use app\common\service\UserSynth;
|
|
|
use think\Db;
|
|
|
use think\Exception;
|
|
|
|
|
@@ -106,6 +108,14 @@ class Order extends Base
|
|
|
* @param name:num type:int default:1 desc:数量
|
|
|
* @param name:add_id type:int default:1 desc:收货地址id
|
|
|
* @param name:remark type:string default:1 desc:订单备注
|
|
|
+ *
|
|
|
+ * @param name:bill_info type:string default:-- desc:发票信息--json【不开票可以不传】
|
|
|
+ * @param name:bill_info.type type:int default:-- desc:类型id
|
|
|
+ * @param name:bill_info.header type:string default:-- desc:抬头名称[公司名称||个人名称]
|
|
|
+ * @param name:bill_info.identify_number type:string default:-- desc:纳税人识别号
|
|
|
+ * @param name:bill_info.email type:string default:-- desc:邮箱
|
|
|
+ * @param name:bill_info.remark type:string default:-- desc:备注
|
|
|
+ *
|
|
|
* @return name:order_id type:int default:1 desc:订单id
|
|
|
*/
|
|
|
public function createOrderImmediately()
|
|
@@ -115,6 +125,8 @@ class Order extends Base
|
|
|
$num = input('post.num');
|
|
|
$add_id = input('post.add_id');
|
|
|
$remark = input('post.remark');
|
|
|
+ $post_bill = input('post.bill_info');
|
|
|
+ $bill_info = json_decode(stripslashes($post_bill),true);
|
|
|
if(!$goods_id || !$spec_id) $this->error('请选择商品');
|
|
|
if($num <=0 ) $this->error('数量有误');
|
|
|
if(!$add_id ) $this->error('请选择收货地址');
|
|
@@ -128,7 +140,6 @@ class Order extends Base
|
|
|
'pro_name' => $add_info['pro_name'],
|
|
|
'city_name' => $add_info['city_name'],
|
|
|
'county_name' => $add_info['county_name'],
|
|
|
- 'street_name' => $add_info['street_name'],
|
|
|
'user_name' => $add_info['name'],
|
|
|
'add_detail' => $add_info['detail'],
|
|
|
'phone' => $add_info['phone'],
|
|
@@ -173,8 +184,12 @@ class Order extends Base
|
|
|
];
|
|
|
GoodsOrderItem::create($order_item);
|
|
|
StoreGoods::where('id',$goods_id)->setDec('stock',$num);
|
|
|
-
|
|
|
StoreGoodsItem::where('id',$spec_id)->setDec('stock',$num);
|
|
|
+ // 申请开票
|
|
|
+ if($order_money > 0 && !empty($bill_info)){
|
|
|
+ $ret_val = UserSynth::buildBillApply($this->user_id, $order_info->id,2,$bill_info,0,1,$bill_info['remark'],0);
|
|
|
+ if($ret_val['code'] != 200) $this->exception($ret_val['msg']);
|
|
|
+ }
|
|
|
Db::commit();
|
|
|
}catch (\Exception $e){
|
|
|
$this->is_commit = false;
|
|
@@ -194,12 +209,23 @@ class Order extends Base
|
|
|
* @param name:ids type:int require:1 default:0 desc:购物车记录id
|
|
|
* @param name:add_id type:int default:1 desc:收货地址id
|
|
|
* @param name:remark type:string default:1 desc:订单备注
|
|
|
+ *
|
|
|
+ * @param name:bill_info type:string default:-- desc:发票信息--json【不开票可以不传】
|
|
|
+ * @param name:bill_info.type type:int default:-- desc:类型id
|
|
|
+ * @param name:bill_info.header type:string default:-- desc:抬头名称[公司名称||个人名称]
|
|
|
+ * @param name:bill_info.identify_number type:string default:-- desc:纳税人识别号
|
|
|
+ * @param name:bill_info.email type:string default:-- desc:邮箱
|
|
|
+ * @param name:bill_info.remark type:string default:-- desc:备注
|
|
|
+ *
|
|
|
* @return name:order_id type:int default:1 desc:订单id
|
|
|
*/
|
|
|
public function createOrderByTrolley()
|
|
|
{
|
|
|
$ids = input('post.ids');
|
|
|
$add_id = input('post.add_id');
|
|
|
+ $remark = input('post.remark');
|
|
|
+ $post_bill = input('post.bill_info');
|
|
|
+ $bill_info = json_decode(stripslashes($post_bill),true);
|
|
|
if(!$ids) $this->error('请选择商品');
|
|
|
if(!$add_id ) $this->error('请选择收货地址');
|
|
|
$ret_data = ['order_id'=>0];
|
|
@@ -227,6 +253,10 @@ class Order extends Base
|
|
|
$order_item = [];// 订单列表
|
|
|
foreach ($trolley_list as $trolley)
|
|
|
{
|
|
|
+ //验证库存
|
|
|
+ if( $trolley['goods_spec']['stock'] < $trolley['num']) $this->exception('商品库存不足');
|
|
|
+ // 扣除库存
|
|
|
+ StoreGoodsItem::stockChange($trolley['spec_id'],$trolley['goods_id'],$trolley['num'],-1);
|
|
|
$price_goods += $trolley['num'] * $trolley['goods_spec']['sell_price'];
|
|
|
$original_total += $trolley['num'] * $trolley['goods_spec']['original_price'];
|
|
|
$total_num +=$trolley['num'];
|
|
@@ -255,6 +285,7 @@ class Order extends Base
|
|
|
'user_name' => $add_info['name'],
|
|
|
'add_detail' => $add_info['detail'],
|
|
|
'phone' => $add_info['phone'],
|
|
|
+ 'remark' => $remark,
|
|
|
];
|
|
|
$price_total = bcadd($price_goods ,$price_express,2);
|
|
|
$order_insert['price_total'] = $price_total;
|
|
@@ -268,6 +299,11 @@ class Order extends Base
|
|
|
(new GoodsOrderItem())->insertAll($order_item);// 生成订单商品详情
|
|
|
ShoppingTrolley::where('id','in',$ids)->delete();// 删除购物车
|
|
|
$ret_data['order_id'] = $order_info->id;
|
|
|
+ // 申请开票
|
|
|
+ if($price_total > 0 && !empty($bill_info)){
|
|
|
+ $ret_val = UserSynth::buildBillApply($this->user_id, $order_info->id,2,$bill_info,0,1,$bill_info['remark'],0);
|
|
|
+ if($ret_val['code'] != 200) $this->exception($ret_val['msg']);
|
|
|
+ }
|
|
|
Db::commit();
|
|
|
}catch (\Exception $e){
|
|
|
$this->ret_msg = $e->getMessage();
|
|
@@ -366,62 +402,61 @@ class Order extends Base
|
|
|
|
|
|
/**
|
|
|
* @title 获取订单列表
|
|
|
- * @desc 订单优惠:int_cash + coupon_cash
|
|
|
+ * @desc 获取订单列表
|
|
|
* @author qc
|
|
|
* @method GET
|
|
|
* @url /api/Order/getOrderList
|
|
|
* @header name:Authorization require:1 desc:Token
|
|
|
* @param name:page type:int default:1 desc:页数
|
|
|
* @param name:page_num type:int default:20 desc:每页数
|
|
|
- * @param name:status type:int default:-1 desc:订单状态(0待支付,1已支付(待发货),2已发货(待收货),3已收货(待评论)4已完成,8已退款,9取消)
|
|
|
+ * @param name:status type:int default:-1 desc:订单状态(0待支付,1已支付(待发货),2已发货(待收货),3已收货(已完成),8已退款,9取消)
|
|
|
* @param name:pay_state type:int default:-1 desc:支付状态(-1全部,0未支付,1已支付)
|
|
|
* @param name:cancel_state type:int default:-1 desc:取消状态(-1全部,0未取消,1已取消)
|
|
|
* @param name:apply_refund type:int default:-1 desc:申请退款状态(-1全部,0未申请||已取消,1已申请)
|
|
|
* @return name:id type:int default:-- desc:订单id
|
|
|
+ * @return name:id type:int default:-- desc:订单id
|
|
|
* @return name:order_no type:string default:-- desc:订单号
|
|
|
- * @return name:price_total type:float default:-- desc:待支付金额(所以优惠完价格+运费)
|
|
|
- * @return name:price_goods type:float default:-- desc:商品金额(用售价计算)
|
|
|
+ * @return name:price_total type:float default:-- desc:待支付金额(商品价格+运费)
|
|
|
+ * @return name:price_goods type:float default:-- desc:商品金额
|
|
|
* @return name:price_express type:float default:-- desc:运费金额
|
|
|
- * @return name:original_total type:float default:-- desc:总原价(下划线)
|
|
|
* @return name:pay_state type:int default:-- desc:支付状态(0未支付1已支付)
|
|
|
* @return name:pay_type type:int default:-- desc:支付方式(1.h5微信,2.h5支付宝,3移动支付(微信),4移动支付(支付宝),5.h5微信内支付)
|
|
|
* @return name:pay_no type:string default:-- desc:支付号
|
|
|
* @return name:pay_at type:string default:-- desc:支付时间
|
|
|
* @return name:cancel_state type:int default:-- desc:取消状态(0未取消1已取消)
|
|
|
* @return name:cancel_at type:string default:-- desc:取消时间
|
|
|
- * @return name:cancel_desc type:string default:-- desc:取消原因
|
|
|
- * @return name:cancel_desc type:string default:-- desc:取消原因
|
|
|
- * @return name:refund_state type:int default:-- desc:退款状态(0未申请1待审核,2审核通过,3审核拒绝)
|
|
|
+ * @return name:refund_state type:int default:-- desc:退款状态(0未申请1待审核,2审核拒绝,3审核通过)
|
|
|
* @return name:express_state type:int default:-- desc:发货状态(0未发货,1已发货,2已签收)
|
|
|
* @return name:express_company_title type:string default:-- desc:发货快递公司名称
|
|
|
* @return name:express_send_no type:string default:-- desc:物流单号
|
|
|
* @return name:express_send_at type:string default:-- desc:发货时间
|
|
|
- * @return name:status type:int default:-- desc:订单状态(0待支付,1已支付(待发货),2已发货(待收货),3已收货(待评论)4已完成,8已退款,9取消)
|
|
|
+ * @return name:status type:int default:-- desc:订单状态(0待支付,1已支付(待发货),2已发货(待收货),3已收货(已完成),8已退款,9取消)
|
|
|
* @return name:create_at type:string default:-- desc:下单时间
|
|
|
- * @return name:integral type:string default:-- desc:使用积分数量
|
|
|
- * @return name:int_cash type:float default:-- desc:使用积分抵扣金额
|
|
|
- * @return name:cl_ids type:string default:-- desc:使用优惠券id串
|
|
|
- * @return name:coupon_cash type:string default:-- desc:使用优惠券抵扣金额
|
|
|
- * @return name:blance type:string default:-- desc:使用余额支付金额
|
|
|
- * @return name:redu_money type:float default:-- desc:订单满减金额
|
|
|
* @return name:remark type:string default:-- desc:订单备注
|
|
|
* @return name:goods_num type:int default:-- desc:订单商品总数量
|
|
|
* @return name:pro_name type:string default:-- desc:省名称(收货地址)
|
|
|
* @return name:city_name type:string default:-- desc:市名称(收货地址)
|
|
|
* @return name:county_name type:string default:-- desc:县区名称(收货地址)
|
|
|
- * @return name:street_name type:string default:-- desc:街道名称(收货地址)
|
|
|
* @return name:add_detail type:string default:-- desc:详细地址(收货地址)
|
|
|
* @return name:user_name type:string default:-- desc:收货人
|
|
|
* @return name:phone type:string default:-- desc:收货人联系电话
|
|
|
- * @return name:act_type type:int default:-- desc:活动类型0无1秒杀2拼团
|
|
|
- * @return name:act_id type:int default:-- desc:活动id
|
|
|
- * @return name:share_user type:int default:-- desc:分享人id
|
|
|
* @return name:order_item type:array default:-- desc:订单商品列表
|
|
|
* @return name:order_item.name type:float default:-- desc:商品名
|
|
|
* @return name:order_item.cover type:float default:-- desc:商品图
|
|
|
* @return name:order_item.sell_price type:float default:-- desc:购买价格
|
|
|
* @return name:order_item.goods_spec type:float default:-- desc:规格
|
|
|
* @return name:order_item.num type:int default:-- desc:数量
|
|
|
+ *
|
|
|
+ * @return name:bill_info type:array default:-- desc:发票申请信息
|
|
|
+ * @return name:bill_info.header type:string default:0 desc:抬头
|
|
|
+ * @return name:bill_info.type type:int default:0 desc:发票类型
|
|
|
+ * @return name:bill_info.email type:string default:0 desc:邮箱
|
|
|
+ * @return name:bill_info.phone type:string default:0 desc:电话
|
|
|
+ * @return name:bill_info.bank type:string default:0 desc:开户行
|
|
|
+ * @return name:bill_info.card_no type:string default:0 desc:银行账号
|
|
|
+ * @return name:bill_info.identify_number type:string default:0 desc:纳税人识别号
|
|
|
+ * @return name:bill_info.bill_img type:string default:0 desc:点子发票url
|
|
|
+ * @return name:bill_info.remark type:string default:0 desc:备注
|
|
|
*/
|
|
|
public function getOrderList()
|
|
|
{
|
|
@@ -431,20 +466,25 @@ class Order extends Base
|
|
|
$refund_state = input('get.apply_refund',-1);
|
|
|
$where = [];
|
|
|
$where[] = ['user_id','=',$this->user_id];
|
|
|
+ $where[] = ['is_deleted','=',0];
|
|
|
if($status > -1) $where[] = ['status','=',$status];
|
|
|
if($pay_state > -1) $where[] = ['pay_state','=',$pay_state];
|
|
|
if($cancel_state > -1) $where[] = ['cancel_state','=',$cancel_state];
|
|
|
if($refund_state == 0) $where[] = ['refund_state','=',$refund_state];
|
|
|
if($refund_state == 1) $where[] = ['refund_state','in','1,2,3,4'];
|
|
|
- $list = GoodsOrder::with(['orderItem'])->where($where)->order('id desc ')
|
|
|
+ $field = 'id,order_no,price_total,price_goods,price_express,create_at,pay_at,pay_type,goods_num,remark,pro_name,city_name,county_name,add_detail,pay_state,user_name,phone,remark,cancel_state,cancel_at,refund_state,express_state,express_company_title,express_send_no,express_send_at';
|
|
|
+ $list = GoodsOrder::with(['orderItem'])->field($field)->where($where)->order('id desc ')
|
|
|
->limit($this->off_set,$this->page_num)
|
|
|
->select()->toArray();
|
|
|
foreach ($list as &$info) {
|
|
|
+ $bill_info = BillApply::field('id,header,type,phone,email,bank,card_no,identify_number,bill_img,remark')->where(['order_type'=>2,'order_id'=>$info['id']])->find();
|
|
|
+ $info['bill_info'] = !empty($bill_info) ? $bill_info->toArray() : null;
|
|
|
foreach ($info['order_item'] as &$v) {
|
|
|
$v['goods_spec'] = str_replace(['::',';;'],[':',';'],$v['goods_spec']);
|
|
|
}
|
|
|
}
|
|
|
- $this->success('',['list'=>$list]);
|
|
|
+ $total_num = GoodsOrder::where($where)->count();
|
|
|
+ $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -460,29 +500,24 @@ class Order extends Base
|
|
|
* @return name:price_total type:float default:-- desc:待支付金额(商品价格+运费)
|
|
|
* @return name:price_goods type:float default:-- desc:商品金额
|
|
|
* @return name:price_express type:float default:-- desc:运费金额
|
|
|
- * @return name:original_total type:float default:-- desc:总原价(下划线)
|
|
|
- * @return name:original_total type:float default:-- desc:总原价(下划线)
|
|
|
* @return name:pay_state type:int default:-- desc:支付状态(0未支付1已支付)
|
|
|
* @return name:pay_type type:int default:-- desc:支付方式(1.h5微信,2.h5支付宝,3移动支付(微信),4移动支付(支付宝),5.h5微信内支付)
|
|
|
* @return name:pay_no type:string default:-- desc:支付号
|
|
|
* @return name:pay_at type:string default:-- desc:支付时间
|
|
|
* @return name:cancel_state type:int default:-- desc:取消状态(0未取消1已取消)
|
|
|
* @return name:cancel_at type:string default:-- desc:取消时间
|
|
|
- * @return name:cancel_desc type:string default:-- desc:取消原因
|
|
|
* @return name:refund_state type:int default:-- desc:退款状态(0未申请1待审核,2审核拒绝,3审核通过)
|
|
|
* @return name:express_state type:int default:-- desc:发货状态(0未发货,1已发货,2已签收)
|
|
|
* @return name:express_company_title type:string default:-- desc:发货快递公司名称
|
|
|
* @return name:express_send_no type:string default:-- desc:物流单号
|
|
|
* @return name:express_send_at type:string default:-- desc:发货时间
|
|
|
- * @return name:status type:int default:-- desc:订单状态(0待支付,1已支付(待发货),2已发货(待收货),3已收货(待评论)4已完成,8已退款,9取消)
|
|
|
+ * @return name:status type:int default:-- desc:订单状态(0待支付,1已支付(待发货),2已发货(待收货),3已收货(已完成),8已退款,9取消)
|
|
|
* @return name:create_at type:string default:-- desc:下单时间
|
|
|
- * @return name:blance type:string default:-- desc:使用余额支付金额(余额抵扣)
|
|
|
* @return name:remark type:string default:-- desc:订单备注
|
|
|
* @return name:goods_num type:int default:-- desc:订单商品总数量
|
|
|
* @return name:pro_name type:string default:-- desc:省名称(收货地址)
|
|
|
* @return name:city_name type:string default:-- desc:市名称(收货地址)
|
|
|
* @return name:county_name type:string default:-- desc:县区名称(收货地址)
|
|
|
- * @return name:street_name type:string default:-- desc:街道名称(收货地址)
|
|
|
* @return name:add_detail type:string default:-- desc:详细地址(收货地址)
|
|
|
* @return name:user_name type:string default:-- desc:收货人
|
|
|
* @return name:phone type:string default:-- desc:收货人联系电话
|
|
@@ -492,21 +527,35 @@ class Order extends Base
|
|
|
* @return name:order_item.sell_price type:float default:-- desc:购买价格
|
|
|
* @return name:order_item.goods_spec type:float default:-- desc:规格
|
|
|
* @return name:order_item.num type:int default:-- desc:数量
|
|
|
+ *
|
|
|
+ * @return name:bill_info type:array default:-- desc:发票申请信息
|
|
|
+ * @return name:bill_info.header type:string default:0 desc:抬头
|
|
|
+ * @return name:bill_info.type type:int default:0 desc:发票类型
|
|
|
+ * @return name:bill_info.email type:string default:0 desc:邮箱
|
|
|
+ * @return name:bill_info.phone type:string default:0 desc:电话
|
|
|
+ * @return name:bill_info.bank type:string default:0 desc:开户行
|
|
|
+ * @return name:bill_info.card_no type:string default:0 desc:银行账号
|
|
|
+ * @return name:bill_info.identify_number type:string default:0 desc:纳税人识别号
|
|
|
+ * @return name:bill_info.bill_img type:string default:0 desc:点子发票url
|
|
|
+ * @return name:bill_info.remark type:string default:0 desc:备注
|
|
|
*/
|
|
|
public function getOrderDetail()
|
|
|
{
|
|
|
$order_id = input('get.order_id');
|
|
|
- $detail = GoodsOrder::where('id',$order_id)->find()->toArray();
|
|
|
+ $field = 'id,order_no,price_total,price_goods,price_express,create_at,pay_at,pay_type,goods_num,remark,pro_name,city_name,county_name,add_detail,pay_state,user_name,phone,remark,cancel_state,cancel_at,refund_state,express_state,express_company_title,express_send_no,express_send_at';
|
|
|
+ $detail = GoodsOrder::where('id',$order_id)->field($field)->find()->toArray();
|
|
|
$detail['order_item'] = (new GoodsOrderItem())->getOrderItem($order_id);
|
|
|
foreach ($detail['order_item'] as &$v) {
|
|
|
$v['goods_spec'] = str_replace(['::',';;'],[':',';'],$v['goods_spec']);
|
|
|
}
|
|
|
+ $bill_info = BillApply::field('id,header,type,phone,email,bank,card_no,identify_number,bill_img,remark')->where(['order_type'=>2,'order_id'=>$detail['id']])->find();
|
|
|
+ $detail['bill_info'] = !empty($bill_info) ? $bill_info->toArray() : null;
|
|
|
$this->success('ok',['detail'=>$detail]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @title 计算商品运费(一个商品id)
|
|
|
- * @desc 计算商品运费(一个商品id)
|
|
|
+ * @title 计算商品运费(一个商品)
|
|
|
+ * @desc 计算商品运费(一个商品)
|
|
|
* @author qc
|
|
|
* @url /api/Order/getGoodsFreight
|
|
|
* @method GET
|
|
@@ -583,10 +632,7 @@ class Order extends Base
|
|
|
foreach ($detail['order_item'] as $item_info) {
|
|
|
// 更改订单详情状态
|
|
|
GoodsOrderItem::update(['status'=>9],['id'=>$item_info['id']]);
|
|
|
- // 商品规格库存返回
|
|
|
- StoreGoodsItem::where('id',$item_info['spec_id'])->setInc('stock',$item_info['num']);
|
|
|
- // 商品总库存增加
|
|
|
- StoreGoods::where('id',$item_info['goods_id'])->setInc('stock',$item_info['num']);
|
|
|
+ StoreGoodsItem::stockChange($item_info['spec_id'],$item_info['goods_id'],$item_info['num']);
|
|
|
}
|
|
|
Db::commit();
|
|
|
}catch (\Exception $e){
|
|
@@ -637,7 +683,6 @@ class Order extends Base
|
|
|
'pro_name' => $add_info['pro_name'],
|
|
|
'city_name' => $add_info['city_name'],
|
|
|
'county_name' => $add_info['county_name'],
|
|
|
- 'street_name' => $add_info['street_name'],
|
|
|
'add_detail' => $add_info['detail'],
|
|
|
'user_name' => $add_info['name'],
|
|
|
'phone' => $add_info['phone'],
|
|
@@ -669,62 +714,7 @@ class Order extends Base
|
|
|
$this->success('已确认收货');
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @title 订单评价
|
|
|
- * @desc 订单评价
|
|
|
- * @author qc
|
|
|
- * @url /api/Order/orderComment
|
|
|
- * @method POST
|
|
|
- * @header name:Authorization require:1 desc:Token
|
|
|
- * @param name:item_id type:int require:1 default:0 desc:订单item表id
|
|
|
- * @param name:content type:string require:1 default:0 desc:评论内容
|
|
|
- * @param name:images type:string default:0 desc:图片
|
|
|
- * @param name:video type:string default:0 desc:视频
|
|
|
- * @param name:goods_core type:int default:0 desc:商品评分
|
|
|
- * @param name:wl_core type:int default:0 desc:物流评分
|
|
|
- * @param name:serve_core type:int default:0 desc:服务评分
|
|
|
- */
|
|
|
- public function orderComment()
|
|
|
- {
|
|
|
- $item_id = input('post.item_id','');
|
|
|
- $content = input('post.content','');
|
|
|
- $images = input('post.images','');
|
|
|
- $video = input('post.video','');
|
|
|
- $goods_core = input('post.goods_core','');
|
|
|
- $wl_core = input('post.wl_core','');
|
|
|
- $serve_core = input('post.serve_core','');
|
|
|
- $item = GoodsOrderItem::get($item_id);
|
|
|
- if(!$item) $this->error('订单不存在');
|
|
|
- $order_info = GoodsOrder::where('id',$item->order_id)->find();
|
|
|
- if($order_info->status < 3) $this->error('请先确认收货');
|
|
|
- GoodsOrderItem::where('id',$item->id)->update(['status'=>4]);
|
|
|
- GoodsOrder::where('id',$item->order_id)->update(['status'=>4]);
|
|
|
- $data = [
|
|
|
- 'user_id' => $this->user_id,
|
|
|
- 'order_id' =>$item->order_id,
|
|
|
- 'goods_id' =>$item->goods_id,
|
|
|
- 'spec_id' =>$item->spec_id,
|
|
|
- 'content' =>$content,
|
|
|
- 'images' =>$images,
|
|
|
- 'video' =>$video,
|
|
|
- 'goods_core' =>$goods_core,
|
|
|
- 'wl_core' =>$wl_core,
|
|
|
- 'serve_core' =>$serve_core,
|
|
|
- ];
|
|
|
- OrderComment::create($data);
|
|
|
- $this->success('评论成功');
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
- /**
|
|
|
- * @title 以下接口为二期需求
|
|
|
- * @desc 以下接口为二期需求
|
|
|
- * @author qc
|
|
|
- * @url /api/Order/secondPhase
|
|
|
- * @method
|
|
|
- * @return name:1 type:string default:-- desc:以下接口为二期需求
|
|
|
- */
|
|
|
- public function secondPhase(){}
|
|
|
|
|
|
/**
|
|
|
* @title 获取物流详情
|
|
@@ -759,8 +749,8 @@ class Order extends Base
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * @title 订单催发
|
|
|
- * @desc 订单催发
|
|
|
+ * @title 发货提醒
|
|
|
+ * @desc 发货提醒
|
|
|
* @author qc
|
|
|
* @url /api/Order/orderUrge
|
|
|
* @method POST
|
|
@@ -796,5 +786,79 @@ class Order extends Base
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @title 申请开票
|
|
|
+ * @desc 申请开票
|
|
|
+ * @author qc
|
|
|
+ * @method POST
|
|
|
+ * @url /api/Order/applyBill
|
|
|
+ * @header name:Authorization require:1 desc:Token
|
|
|
+ * @param name:order_id type:string default:1 desc:订单id
|
|
|
+ * @param name:type type:int default:-- desc:类型id
|
|
|
+ * @param name:header type:string default:-- desc:抬头名称[公司名称||个人名称]
|
|
|
+ * @param name:identify_number type:string default:-- desc:纳税人识别号
|
|
|
+ * @param name:email type:string default:-- desc:邮箱
|
|
|
+ * @param name:remark type:string default:-- desc:备注
|
|
|
+ */
|
|
|
+
|
|
|
+ public function applyBill()
|
|
|
+ {
|
|
|
+ $order_id = input('post.order_id');
|
|
|
+ $post = input('post.');
|
|
|
+ $order_info = GoodsOrder::where('id',$order_id)->find()->toArray();
|
|
|
+ if(!$order_info['pay_state'])$this->error('订单未支付');
|
|
|
+ if(BillApply::checkBillApply($order_id,2)) $this->error('已申请开票');
|
|
|
+ $ret_val = UserSynth::buildBillApply($this->user_id, $order_id, 2,$post,0,1,$post['remark']);
|
|
|
+ if($ret_val['code'] != 200) $this->error($ret_val['msg']);
|
|
|
+ $this->success('申请成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @title 订单商品添加购物车
|
|
|
+ * @desc 订单商品添加购物车
|
|
|
+ * @author qc
|
|
|
+ * @method POST
|
|
|
+ * @url /api/Order/addTrolleyFromOrder
|
|
|
+ * @header name:Authorization require:1 desc:Token
|
|
|
+ * @param name:order_id type:string default:1 desc:订单id
|
|
|
+ */
|
|
|
+ public function addTrolleyFromOrder(){
|
|
|
+ $order_id = input('post.order_id');
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ $detail = GoodsOrder::with('orderItem')->where('id',$order_id)->find()->toArray();
|
|
|
+ foreach ($detail['order_item'] as $item_info) {
|
|
|
+ $goods_info = StoreGoods::getGoodsSpec($item_info['goods_id'],$item_info['spec_id']);
|
|
|
+ if(!$goods_info) $this->exception('商品已下架');
|
|
|
+ if(empty($goods_info['item_list'])) $this->exception('商品规格已下架');
|
|
|
+ if($goods_info['item_list'][0]['stock'] < $item_info['num'])$this->exception('库存不足');
|
|
|
+ //某商品某规格是否已经添加购物车
|
|
|
+ $trolley_id = ShoppingTrolley::checkTrolley($this->user_id,$item_info['goods_id'],$item_info['spec_id']);
|
|
|
+ // 添加到购物车
|
|
|
+ if($trolley_id) {
|
|
|
+ ShoppingTrolley::where('id',$trolley_id)->setInc('num',$item_info['num']);
|
|
|
+ }else{
|
|
|
+ $trolley_info = [
|
|
|
+ 'user_id' => $this->user_id,
|
|
|
+ 'goods_id' => $item_info['goods_id'],
|
|
|
+ 'spec_id' => $item_info['spec_id'],
|
|
|
+ 'goods_no' => $goods_info['item_list'][0]['goods_no'],
|
|
|
+ 'num' => $item_info['num'],
|
|
|
+ ];
|
|
|
+ ShoppingTrolley::create($trolley_info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ }catch (\Exception $e){
|
|
|
+ $this->ret_msg = $e->getMessage();
|
|
|
+ $this->is_commit = false;
|
|
|
+ Db::rollback();
|
|
|
+ }
|
|
|
+ $this->is_commit ? $this->success('添加成功') : $this->error($this->ret_msg);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|