self::BX]; $count = $userModel->where($where)->count(); $pageNum = ceil($count / $pageSize); var_dump("共{$pageNum}页"); for ($i = 1; $i <= $pageNum; $i++) { $res = $userModel->order(['intMemberID' => 'asc'])->where($where)->page($i, $pageSize)->select(); $res = HelperService::object2Arr($res); foreach ($res as $v) { $data = [ 'user_no' => $this->randomNum(), 'mobile' => $v['strMobilePhone'], 'name' => $v['strMemberNickName'], 'birthday' => $v['datBirthday'], 'sex' => $v['blnSex'] == 0 ? 1 : 2, 'header_img' => $v['strHeaderImg'], 'nickname' => $v['strMemberNickName'], 'add_ts' => strtotime($v['datDateTime']), 'smdd_openid' => $v['strWxXcxOpenID'], 'usable_score' => $v['intBonus'], 'total_score' => $v['intBonusCumulative'], 'other_id' => $v['strMemberCode'], 'bloc_code' => 'BAIXIONG' ]; $this->insertMemberData($data); } } } /** * */ public function couponData() { var_dump('先转移券的信息'); $countConfigData = $this->couponConfig(); var_dump('获取券的配置信息完毕'); $memberCouponModel = new MemberCouponModel(); $userModel = new MemberModel(); $where = ['strHQCode' => self::BX]; // $where['strCouponCode'] = 13; $where['strCouponCode'] = ['in', array_keys($countConfigData)]; $count = $memberCouponModel->where($where)->count(); $userCoupon = new UserCouponModel(); $pageSize = 200; $pageNum = ceil($count / $pageSize); for ($i = 0; $i < $pageNum; $i++) { $couponList = $memberCouponModel->where($where)->order(['intMemberCouponID' => 'asc'])->page($i, $pageSize)->select(); $couponList = HelperService::object2Arr($couponList); foreach ($couponList as $couponInfo) { $userNo = $userModel->where(['other_id' => $couponInfo['strMemberCode']])->value('user_no'); if ($couponInfo['blnVoid'] == 0){ if ($couponInfo['blnState'] == 0){ $status = 1; }else{ $status = 2; } }else{ $status = 4; } $data = [ 'user_no' => $userNo, 'coupon_id' => 13, 'start_time' => strtotime($couponInfo['datBegin']), 'end_time' => strtotime($couponInfo['datEnd']), 'use_time' => strtotime($couponInfo['datVerificationTime']), 'status' => $status, 'source_type' => 1, 'add_ts' => strtotime($couponInfo['datDateTime']), ]; $userCoupon->insert($data); var_dump($userNo); } } } /** * 转移现金券的配置 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function couponConfig() { $couponModel = new CouponModel(); // $bxCoupon = new \app\common\model\bx\CouponModel(); //select * from tabPromoConfig where strHQCode='126' and blnState=0 and strPromoMode='Coupon' and strCouponTypeCode='1001' $data = []; $couponList = $couponModel->getCoupon(); foreach ($couponList as $info) { // $id = $bxCoupon->insertGetId([ // 'coupon_name' => $info['strValue2'], // 'type' => $info['intValidityType'], // 'full_money' => $info['strValue'], // 'discount_money' => $info['strValue1'], // 'start_time' => strtotime($info['datBeginDate']), // 'end_time' => strtotime($info['datEndDate']), // 'receive_day' => $info['intValidityBegin'], // 'day' => $info['intValidityEnd'], // 'remark' => $info['strValue3'], // 'bloc_code' => 'BAIXIONG', // ]); $data[$info['strCode']] = 13; } return $data; } protected function insertMemberData($data = [], $num = 0) { $memberModel = new MemberModel(); try { $memberModel->insert($data); } catch (\Exception $e) { var_dump($e->getMessage()); if ($num > 5) { return; } $this->insertMemberData($data); } } }