|
|
@@ -102,7 +102,8 @@ class PropertyActivityLogic extends BaseLogic
|
|
|
{
|
|
|
if($reserved_type === 'block_data'){
|
|
|
$reserved_field = ['id','recommend_weight','goods_name'];
|
|
|
- foreach ($data as &$item) {
|
|
|
+ foreach ($data as $key => &$item) {
|
|
|
+ $data[$key]['block_key'] = $key+1;
|
|
|
foreach ($item['goods'] as &$good) {
|
|
|
foreach ($good as $k=>$v) {
|
|
|
if(!in_array($k,$reserved_field)){
|
|
|
@@ -189,25 +190,12 @@ class PropertyActivityLogic extends BaseLogic
|
|
|
{
|
|
|
try {
|
|
|
$activity_list = PropertyActivity::select()->toArray();
|
|
|
- foreach ($activity_list as $item) {
|
|
|
- if(!empty($itemp['coupon_data'])){
|
|
|
- continue;
|
|
|
- }
|
|
|
- $coupon_list = CouponRules::with(['couponWithCategory'=>function(Query $query){
|
|
|
- $query->field('id,name');
|
|
|
- }])->where('property_activity_id',$item['id'])
|
|
|
- ->field(['id','code', 'amount', 'coupon_type','amount_require', 'discount_ratio', 'event_name', 'expire_time', 'max_deductible_price', 'mold_type', 'server_category_name', 'voucher_status', 'voucher_count','remaining_count','property_activity_id'])
|
|
|
- ->select()
|
|
|
- ->toArray()??[];
|
|
|
- foreach($coupon_list as $k => $v){
|
|
|
- $v['goods_category_ids'] = array_column($v['couponWithCategory'],'id');
|
|
|
- $coupon_list[$k] = $v;
|
|
|
- }
|
|
|
- if($coupon_list){
|
|
|
- $data = [
|
|
|
- 'coupon_data' => json_encode(self::configureReservedField($coupon_list??[], 'coupon_data')),
|
|
|
- ];
|
|
|
- PropertyActivity::where('id',$item['id'])->update($data);
|
|
|
+ foreach ($activity_list as &$item) {
|
|
|
+ if(!empty($item['block_data'])){
|
|
|
+ for ($i = 0; $i < count($item['block_data']); $i++) {
|
|
|
+ $item['block_data'][$i]['block_key'] = $i+1;
|
|
|
+ }
|
|
|
+ PropertyActivity::where('id',$item['id'])->update(['block_data'=>json_encode($item['block_data'])]);
|
|
|
}
|
|
|
}
|
|
|
return true;
|