|
|
@@ -15,9 +15,11 @@
|
|
|
namespace app\adminapi\logic\property;
|
|
|
|
|
|
|
|
|
+use app\common\model\coupon\CouponRules;
|
|
|
use app\common\model\property\PropertyActivity;
|
|
|
use app\common\logic\BaseLogic;
|
|
|
use app\common\service\wechat\WeChatMnpService;
|
|
|
+use think\db\Query;
|
|
|
use think\Exception;
|
|
|
use think\facade\Db;
|
|
|
use think\facade\Log;
|
|
|
@@ -183,5 +185,35 @@ class PropertyActivityLogic extends BaseLogic
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public static function newDataExecute()
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ return $e->getMessage();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|