| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?php
- namespace app\command;
- use app\common\model\user\UserCertification;
- use app\common\repositories\merchant\order\OrderGzcRepository;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\facade\Db;
- use think\facade\Log;
- class GzcAddByBillCommand extends Command
- {
- protected function configure()
- {
- // 配置命令名称及描述
- $this->setName('gzcAddByBill')
- ->setDescription('从bill表中查询未提交到公证处的养老金记录,并提交公证处');
- }
- protected function execute(Input $input, Output $output)
- {
- // 在这里执行任务的具体内容
- $output->writeln('定时任务执行中...');
- $nowTime = time();
- $this->billGzcAdd($nowTime);
- $output->writeln('定时任务执行完成');
- }
- /**
- * 线下支付订单公证处IN10入账
- * @param $nowTime
- * author: php迷途小书童
- * created: 2021/3/20 9:26
- */
- public function billGzcAdd($nowTime)
- {
- /** @var OrderGzcRepository $OrderGzcRepository */
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- $cursor = Db::name('user_bill')
- ->where('status', 1)
- ->where('is_gzc', 0)
- ->where('commission_type', 5)
- ->select()
- ->toArray();
- if ($cursor) {
- foreach ($cursor as $bill) {
- $type_shop = $bill['type_shop'] ?? 0;
- switch ($type_shop) {
- case "0":
- $online = $cursor = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
- break;
- case "1":
- $online = Db::table('rrx_order_pdd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
- break;
- case "2":
- $online = Db::table('rrx_order_vip')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
- break;
- case "3":
- $online = Db::table('rrx_order_su')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
- break;
- case "4":
- $online = '';
- break;
- case "5":
- $online = Db::table('rrx_order_tb')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
- break;
- case "6":
- $online = Db::table('rrx_order_jd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
- break;
- case "7":
- $online = '';
- break;
- case "8":
- $online = '';
- break;
- case "9":
- $online = Db::table('rrx_order_huafei')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
- break;
- default:
- $online = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
- }
- if (!$online) {
- Log::info($bill['uid'] . '查询不到订单');
- continue;
- }
- $certification = UserCertification::getInstance()->where('uid', $bill['uid'])->find();
- if (!$certification) {
- Log::info($online['uid'] . '没有实名认证');
- continue;
- }
- $pension = $bill['number'] ?? 0;
- if ($pension <= 0) {
- Log::info($online['order_sn'] . 'pension' . $pension);
- continue;
- }
- //新增入账明细记录
- list($msec, $sec) = explode(' ', microtime());
- $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
- $orderId = 'IN10' . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369));
- $create = [
- 'uid' => $online['uid'],
- 'platform_no' => $orderId,
- 'account_type' => 1,
- 'user_name' => $certification['user_name'],
- 'mobile' => $certification['mobile'],
- 'user_card' => $certification['user_card'],
- 'pension' => $pension,
- 'order_type' => $type_shop,
- 'out_trade_no' => $online['order_sn'],
- 'link_id' => $bill['bill_id']
- ];
- $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
- $check = Db::name("gzc_logs")->where("link_id", $bill['bill_id'])->where("order_type", $type_shop)->count();
- if ($test_user == 0 && $check <= 0) {
- $OrderGzcRepository->create($create);
- Db::name('user_bill')
- ->where('bill_id', $bill['bill_id'])
- ->where('commission_type', 5)
- ->update([
- 'is_gzc' => 1,
- 'gzc' => 1
- ]);
- }
- }
- }
- }
- }
|