where(['id'=>$data['order_goods_id']])->field('goods_name,price,true_price,goods_cover')->find(); return $info; } } /** * @author chenniang * @DataTime: 2020-09-29 11:04 * @功能说明:添加 */ public function dataAdd($data){ $res = $this->insert($data); return $res; } /** * @author chenniang * @DataTime: 2020-09-29 11:05 * @功能说明:编辑 */ public function dataUpdate($dis,$data){ $res = $this->where($dis)->update($data); return $res; } /** * @author chenniang * @DataTime: 2020-09-29 11:06 * @功能说明:列表 */ public function dataList($dis,$page){ $data = $this->where($dis)->order('id desc')->paginate($page)->toArray(); return $data; } /** * @author chenniang * @DataTime: 2020-09-29 11:43 * @功能说明: */ public function dataInfo($dis){ $data = $this->where($dis)->find(); return !empty($data)?$data->toArray():[]; } /** * @author chenniang * @DataTime: 2021-03-22 11:12 * @功能说明:添加商品子订单 */ public function orderGoodsAdd($order_goods,$order_id){ $goods_model = new Service(); foreach ($order_goods as $v){ $ser_status = $goods_model->where(['id'=>$v['service_id']])->value('status'); if($ser_status!=1){ return ['code'=>500,'msg'=>'服务已经下架']; } $insert = [ 'uniacid' => $v['uniacid'], 'order_id' => $order_id, 'goods_name' => $v['title'], 'goods_cover' => $v['cover'], 'price' => $v['price'], 'true_price' => round($v['true_price']/$v['num'],5), 'num' => $v['num'], 'goods_id' => $v['service_id'], 'time_long' => $v['time_long'], 'order_goods_id' => $v['order_goods_id'], 'pay_price' => $v['pay_price'], 'material_price' => $v['material_price'], 'coupon_discount'=> !empty($v['coupon_discount'])?$v['coupon_discount']:0, ]; $res = $this->dataAdd($insert); if($res!=1){ return ['code'=>500,'msg'=>'下单失败']; } //减少库存 增加销量 $res = $goods_model->setOrDelStock($v['service_id'],$v['num']); if(!empty($res['code'])){ return $res; } } return true; } }