修改update冲突

master
chenzhi 5 years ago
commit 94243a5ea6

@ -1793,4 +1793,19 @@ function all_pay_way_other($type=false)
$pay_way[15]=array('key'=>15,'value'=>'双乾支付-快捷');
return $pay_way;
}
function getMonthOther() {
$start = date("Y-m", strtotime("now"));
//开始月份
$range = [];
$i = 0;
do {
$month = date('Y-m', strtotime($start . ' - ' . $i . ' month'));
$range[] = $month;
$i++;
} while ($i<36);
return $range;
}
?>

@ -9,7 +9,7 @@ use Base\Service\PromoteService as PromoteService;
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
class MendController extends ThinkController {
public $tempid = 0;
public function lists($p=1){
$this->m_title = '推广补链';
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Mend/lists','status'=>1])->find());
@ -124,7 +124,7 @@ class MendController extends ThinkController {
// $this->error('在订单日期内含有已经结算的订单,无法补链');
// }
if(self::checkSpend(strtotime($_POST['order_time']),$_POST['account'])){
$this->error('在订单日期内含有已经结算的订单,无法补链');
$this->error("在订单日期内含有已经结算的订单,无法补链。如订单:{$this->tempid}");
}
if(self::checkPromote(strtotime($_POST['order_time']),$_POST['account'])){
$this->error('在订单日期内含有多个推广员,无法补链');
@ -169,14 +169,45 @@ class MendController extends ThinkController {
* 2020.1.3 之后判断订单是否已经结算
*/
private function checkSpend($order_time,$account){
//获取所有涉及订单
$map = array(
"pay_status"=>1,
"user_account"=>$account,
"pay_time"=>array("EGT",$order_time),
"selle_status"=>1
"pay_time"=>array("EGT",$order_time)
);
$spendlist = M("Spend","tab_")->field("id,selle_status,pay_order_number")->where($map)->select();
if(count($spendlist) < 1){
return false;
}
//获取所有未审核
$withmap = array(
"status"=>0,
"settlement_begin_time"=>array("EGT",$order_time),
"settlement_end_time"=>array("ELT",$order_time)
);
$flag = M("Spend","tab_")->where($map)->count();
if($flag > 0) return true;
$withspendlist = M("withdraw","tab_")->field("spend_ids")->select();
$dsh_list = false;
if(!empty($withspendlist)){
//获取所有涉及订单
foreach ($withspendlist as $value) {
$dsh_list .= (','.$value['spend_ids']);
}
}
if($dsh_list){
$dsh_list = array_flip(explode(",",$dsh_list));
}
foreach($spendlist as $k=>$v){
if($v['selle_status'] == 1){
$this->tempid = $v['pay_order_number'];
return true; //有已结算
}
if($dsh_list && $dsh_list[$v['id']]){
$this->tempid = $v['pay_order_number'];
return true; //有待审核的
}
}
return false;
}

@ -1391,4 +1391,87 @@ class QueryController extends ThinkController
}
}
public function marketList($p=1) {
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
$arraypage = $page;
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
$map = [];
if ($_REQUEST['promote_id']) {
$map['root_id'] = $_REQUEST['promote_id'];
}
if ($_REQUEST['game_name']) {
$map['game_names'] = $_REQUEST['game_name'];
}
if ($_REQUEST['count_date']) {
$map['my_time'] = $_REQUEST['count_date'];
}
if ($_REQUEST['device']) {
$map['game_name'] = ['like','%'.$_REQUEST['device'].'%'];
}
//获取spend表中的数据同时根据会长id进行group分类
$data = M('Spend','tab_')
->field("FROM_UNIXTIME(pay_time,'%Y-%m') as my_time,sum(pay_amount) as pay_amount,game_id,game_name,SUBSTRING_INDEX(`game_name`,\"(\",1) as game_names,promote_id,promote_account,company_relation,company_belong,CASE WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1)='' THEN promote_id ELSE SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1) END as root_id ")
->join("left join tab_promote on promote_id = tab_promote.id")
->where(['pay_status'=>1])
->group("my_time,game_names,root_id")
->order("my_time Desc")
->select(false);
$count = M()->table('('.$data.') as a')
->field("my_time,pay_amount,game_id,game_names,promote_id,promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account")
->join("left join tab_promote on root_id = tab_promote.id")
->group("my_time,game_names,root_id")
->where($map)
->order("my_time Desc")
->select(false);
//关联表获取会长账号名
$data = M()->table('('.$data.') as a')
->field("my_time,pay_amount,game_id,game_name,game_names,promote_id,promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account")
->join("left join tab_promote on root_id = tab_promote.id")
->page($page,$row)
->where($map)
->group("my_time,game_names,root_id")
->order("my_time Desc")
->select();
$pagecount = M()->table('('.$count.') as a')->count();
foreach($data as $key => $value) {
$data[$key]['upstream'] = $value['pay_amount'] * 0.2;
$data[$key]['downstream'] = $value['pay_amount'] * 0.7;
$data[$key]['highquality'] = ($value['pay_amount']-$data[$key]['upstream']-$data[$key]['downstream']) * (1-0.0672);
$data[$key]['company_belong'] = $data[$key]['company_belong']?'外团':'内团';
$data[$key]['company_relation'] = $data[$key]['company_relation']?'只维护':'自主开发及维护';
}
$page = set_pagination($pagecount, $row);
if ($page) {
$this->assign('_page', $page);
}
$this->assign('data',$data);
$this->display();
}
}

@ -957,3 +957,20 @@ MODIFY COLUMN `mime` char(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NU
ALTER TABLE `tab_spend`
MODIFY COLUMN `selle_status` int(11) NOT NULL DEFAULT 0 COMMENT '渠道结算 0未结算1 结算',
MODIFY COLUMN `selle_ratio` double(5, 2) DEFAULT 0.00 COMMENT '渠道分成比例';
-- 推广公会归属管理 2020-1-1 刘伟文
CREATE TABLE `tab_promote_belong` (
`id` int(11) NOT NULL,
`promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
`verify_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '审核状态:0-待审核1-审核通过2-审核拒绝',
`company_belong` tinyint(1) NOT NULL DEFAULT '0' COMMENT '工会归属0-内团1-外团',
`company_relation` tinyint(1) NOT NULL DEFAULT '0' COMMENT '工会关系0-自主开发及维护1-只维护',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`applicant_id` int(11) NOT NULL DEFAULT '0' COMMENT '申请人(后台管理员)id',
`approver_id` int(11) NOT NULL DEFAULT '0' COMMENT '确认人(后台管理员)id',
`applicant_time` int(11) DEFAULT '0' COMMENT '申请时间',
`verify_time` int(11) DEFAULT '0' COMMENT '审批时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='推广公会归属管理';

Loading…
Cancel
Save