Пример #1
0
 public function actionCs4gCharge($filename = 'cs4g-charge.csv')
 {
     $filepathname = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'imported_data' . DIRECTORY_SEPARATOR . $filename;
     $fh = fopen($filepathname, "r");
     while (!feof($fh)) {
         $line = trim(fgets($fh));
         if (empty($line) || strlen($line) == 0) {
             continue;
         }
         $fields = explode(",", $line);
         $charge_mobile = trim($fields[0]);
         $charge_ammount = trim($fields[1]);
         if (empty($charge_ammount) || strlen($charge_ammount) == 0 || $charge_ammount == 0) {
             continue;
         }
         if (empty($charge_mobile) || strlen($charge_mobile) == 0 || strlen($charge_mobile) != 11) {
             continue;
         }
         $openidbindmobile = \app\models\OpenidBindMobile::findOne(['gh_id' => \app\models\MGh::GH_XIANGYANGUNICOM, 'mobile' => $charge_mobile]);
         if (!empty($openidbindmobile)) {
             $wx_user = $openidbindmobile->user;
             if (!empty($wx_user)) {
                 echo $wx_user->nickname . " mobile " . $charge_mobile . " charged " . $charge_ammount . PHP_EOL;
                 $user_account = new \app\models\MUserAccount();
                 $user_account->gh_id = $wx_user->gh_id;
                 $user_account->openid = $wx_user->openid;
                 //                    $user_account->scene_id = $wx_user->staff->scene_id;
                 $user_account->cat = \app\models\MUserAccount::CAT_DEBIT_FAN;
                 $user_account->amount = $charge_ammount * 100;
                 $user_account->memo = "4G测速";
                 $user_account->charge_mobile = $charge_mobile;
                 $user_account->save(false);
                 $user_account = new \app\models\MUserAccount();
                 $user_account->gh_id = $wx_user->gh_id;
                 $user_account->openid = $wx_user->openid;
                 //                    $user_account->scene_id = $wx_user->staff->scene_id;
                 $user_account->cat = \app\models\MUserAccount::CAT_CREDIT_CHARGE_MOBILE;
                 $user_account->amount = -$charge_ammount * 100;
                 $user_account->memo = "4G测速";
                 $user_account->charge_mobile = $charge_mobile;
                 $user_account->save(false);
             } else {
                 echo "can't find charge mobile " . $charge_mobile . "({$charge_ammount})" . PHP_EOL;
             }
         }
     }
     fclose($fh);
 }
Пример #2
0
 public function actionChonghuafeiajax()
 {
     $czhm = $_GET['czhm'];
     $czje = $_GET['czje'];
     $gh_id = $_GET['gh_id'];
     $openid = $_GET['openid'];
     //        $wx_user = \app\models\MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
     //        if (empty($wx_user)) return json_encode(['code' => -1]);
     $user_account = new \app\models\MUserAccount();
     $user_account->gh_id = $gh_id;
     $user_account->openid = $openid;
     $user_account->cat = \app\models\MUserAccount::CAT_CREDIT_CHARGE_MOBILE;
     $user_account->amount = -$czje * 100;
     $user_account->memo = "提现充话费申请";
     $user_account->charge_mobile = $czhm;
     $user_account->status = \app\models\MUserAccount::STATUS_CHARGE_REQUEST;
     $user_account->save(false);
     return json_encode(['code' => 0]);
 }