|
@@ -56,23 +56,25 @@ class CouponController extends Curd
|
|
|
$item['coupon_use_member'] = 'all';
|
|
|
} else {
|
|
|
$item['coupon_use_member'] = 'condition';
|
|
|
- }
|
|
|
- $where = str_replace('`', '', urldecode($couponJson['member']['where']));
|
|
|
- $whereArr = explode('=', $where);
|
|
|
- if (isset($whereArr[0]) && trim($whereArr[0]) == 'member_is_vip') {
|
|
|
- $item['condition'] = 'is_vip';
|
|
|
- } else if (isset($whereArr[0]) && trim($whereArr[1]) == 'member_classify') {
|
|
|
- if (isset($whereArr[1]) && trim($whereArr[1]) == 'MEMBER') {
|
|
|
- $item['condition'] = 'is_member';
|
|
|
- } else if (isset($whereArr[1]) && trim($whereArr[1]) == 'EMPLOY') {
|
|
|
- $item['condition'] = 'is_employ';
|
|
|
+ $where = str_replace('`', '', urldecode($couponJson['member']['where']));
|
|
|
+ $whereArr = explode('=', $where);
|
|
|
+// dump($whereArr);
|
|
|
+// dump($whereArr[1]);
|
|
|
+ if (isset($whereArr[1]) && trim($whereArr[1]) == 'member_is_vip') {
|
|
|
+ $item['condition'] = 'is_vip';
|
|
|
+ } else if (isset($whereArr[1]) && trim($whereArr[1]) == 'member_classify') {
|
|
|
+ if (isset($whereArr[1]) && trim($whereArr[1]) == 'MEMBER') {
|
|
|
+ $item['condition'] = 'is_member';
|
|
|
+ } else if (isset($whereArr[1]) && trim($whereArr[1]) == 'EMPLOY') {
|
|
|
+ $item['condition'] = 'is_employ';
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (isset($couponJson['premises'])) {
|
|
|
$item['premises'] = $couponJson['premises'];
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$item['premises_range'] = 'all';
|
|
|
}
|
|
|
}
|
|
@@ -106,19 +108,18 @@ class CouponController extends Curd
|
|
|
if ($this->validate && !$this->validateClass->scene('add')->check($request->post())) {
|
|
|
return json_fail($this->validateClass->getError());
|
|
|
}
|
|
|
- $goods = $request->post('goodsContentList',[]);
|
|
|
- if(empty($goods)){
|
|
|
+ $goods = $request->post('goodsContentList', []);
|
|
|
+ if (empty($goods)) {
|
|
|
return json_fail("请选择关联的产品");
|
|
|
}
|
|
|
|
|
|
-// return json_fail("请选择关联的产品");
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
$data = $this->insertInput($request);
|
|
|
+ dump($data);
|
|
|
$this->doInsert($data);
|
|
|
// 关联优惠券和商品、规格
|
|
|
- $this->insertCouponGoods($goods,$data['coupon_id']);
|
|
|
-
|
|
|
+ $this->insertCouponGoods($goods, $data['coupon_id']);
|
|
|
Db::commit();
|
|
|
|
|
|
return json_success('success');
|
|
@@ -146,17 +147,17 @@ class CouponController extends Curd
|
|
|
public function insertCouponGoods($goods, $couponId)
|
|
|
{
|
|
|
try {
|
|
|
- foreach ($goods as $good){
|
|
|
+ foreach ($goods as $good) {
|
|
|
CouponGoods::insert([
|
|
|
- 'join_goods_coupon_id'=>$couponId,
|
|
|
- 'join_coupon_goods_id'=>$good['goods_id'],
|
|
|
- 'join_coupon_goods_sku_id'=>$good['sku_id'],
|
|
|
- 'coupon_goods_json'=>'[]',
|
|
|
- 'coupon_goods_extend_json'=>'[]',
|
|
|
- 'coupon_goods_addtimes'=>time()
|
|
|
+ 'join_goods_coupon_id' => $couponId,
|
|
|
+ 'join_coupon_goods_id' => $good['goods_id'],
|
|
|
+ 'join_coupon_goods_sku_id' => $good['sku_id'],
|
|
|
+ 'coupon_goods_json' => '[]',
|
|
|
+ 'coupon_goods_extend_json' => '[]',
|
|
|
+ 'coupon_goods_addtimes' => time()
|
|
|
]);
|
|
|
}
|
|
|
- }catch (\Exception $e){
|
|
|
+ } catch (\Exception $e) {
|
|
|
throw new BusinessException("关联产品失败");
|
|
|
}
|
|
|
}
|