实惠等产品退卡

This commit is contained in:
wanyongkang
2020-12-05 19:53:28 +08:00
parent 0bb02fd81b
commit 4ed41b02b5
2 changed files with 58 additions and 2 deletions

View File

@@ -45,7 +45,7 @@ class Sql
$flag = false;
if (is_array($value)) {
if (in_array($value[0], $ins)) {
$this->filter .= ' `' . $key . '` ' . $value[0] . '(' . implode(',', $value[1]) . ')';
$this->filter .= ' `' . $key . '` ' . $value[0] . '(\'' . implode('\',\'', $value[1]) . '\')';
} else {
$param_key = $this->paramIsExit($key, $this->param);
$this->filter .= ' `' . $key . '` ' . $value[0] . ' :' . $param_key;
@@ -58,7 +58,7 @@ class Sql
} else {
if (is_array($value)) {
if (in_array($value[0], $ins)) {
$this->filter .= ' AND `' . $key . '` ' . $value[0] . '(' . implode(',', $value[1]) . ')';
$this->filter .= ' AND `' . $key . '` ' . $value[0] . '(\'' . implode('\',\'', $value[1]) . '\')';
} else {
$param_key = $this->paramIsExit($key, $this->param);
$this->filter .= ' AND `' . $key . '` ' . $value[0] . ' :' . $param_key;

56
script/test/test.php Normal file
View File

@@ -0,0 +1,56 @@
<?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-03 18:23:43
* @LastEditors: Please set LastEditors
* @LastEditTime: 2020-12-05 19:52:44
*/
$is_script = 1;
include_once __DIR__ . '/../../index.php';
use app\api\model\ProductOrder as ProductOrderModel;
use enum\order\ProductOrder as ProductOrderEnum;
use app\manager\model\ProductAccount;
$product_order_model = new ProductOrderModel;
$product_order_enum = new ProductOrderEnum;
$product_account_model = new ProductAccount;
// SELECT * FROM `product_order` WHERE OrderType=5 AND UpdateTime<'2020-12-06' AND UpdateTime>'2020-12-03' AND ProductId IN(3,7,9,10,15,16)
$list = $product_order_model->getList("OrderType=5 AND UpdateTime<'2020-12-06' AND UpdateTime>'2020-12-03' AND ProductId IN(3,7,9,10,15,16)");
$account_list = [];
$order_list = [];
foreach ($list as $info){
$account_list[] = $info['Accounts'];
$order_list[$info['Accounts']] = $info;
}
$account_model_list = $product_account_model->getList(['Account'=>['in',$account_list]]);
foreach ($account_model_list as $account) {
$endtime = strtotime($account['EndTime']) + handle_time($order_list[$account['Account']]['RefundRestTime']);
$data['EndTime'] = date('Y-m-d H:i:s', $endtime);
$product_account_model->updateOne(['Account'=>$account['Account']], $data);
}
//将剩余时间进行处理切割转换为秒
function handle_time($rest_time)
{
$time1 = explode('天', $rest_time);
$time2 = explode('时', $time1[1]);
$time3 = explode('分', $time2[1]);
$time = $time1[0] * 86400 + $time2[0] * 3600 + $time3[0] * 60;
return $time;
}