edit-admin-add_pay_log
This commit is contained in:
@@ -638,7 +638,7 @@ class Orders extends HD_Controller
|
||||
$where = [
|
||||
'o_id' => $oid,
|
||||
'status' => 1,
|
||||
'pay_price!=' => 0
|
||||
'pay_price>' => 0
|
||||
];
|
||||
$sum = $this->app_liche_orders_model->sum('total_price', $where); //已收金额
|
||||
$need_price = $this->orders_entity->recevable_price($oid); //应收金额
|
||||
@@ -756,32 +756,29 @@ class Orders extends HD_Controller
|
||||
$p_row = $this->app_liche_orders_model->get(['o_id'=>$params['id'],'pid'=>0],'id');
|
||||
$where = [
|
||||
'o_id' => $params['id'],
|
||||
'status>=' => 0,
|
||||
'((pid>0 and type!=5) or (pid=0 and type=5))' => null
|
||||
'status' => 1,
|
||||
'pay_price>' => 0
|
||||
];
|
||||
$count = $this->app_liche_orders_model->count($where);
|
||||
if ($count) {
|
||||
$rows = $this->app_liche_orders_model->select($where, 'type asc', $page, $size, 'id,total_price,type,pay_time,mch_id,descrip,status,pid');
|
||||
$rows = $this->app_liche_orders_model->select($where, 'id desc', $page, $size, 'id,total_price,type,pay_time,mch_id,descrip,status,pid');
|
||||
$type_arr = $this->app_liche_orders_model->get_type_arr();
|
||||
foreach ($rows as $item) {
|
||||
$company = '';
|
||||
if ($item['mch_id']) {
|
||||
$company = $this->sys_company_model->get(['wx_mchid' => $item['mch_id']], 'short');
|
||||
}
|
||||
$type_cn = $item['type']==3 && $item['pid']==$p_row['id'] ? '尾款-主订单' : $type_arr[$item['type']];
|
||||
$list[] = [
|
||||
'id'=> $item['id'],
|
||||
'money' => $item['total_price'],
|
||||
'type_cn' => $type_cn,
|
||||
'type_cn' => $type_arr[$item['type']],
|
||||
'pay_time' => $item['pay_time'],
|
||||
'status' => $item['status'],
|
||||
'company' => $company ? $company['short'] : '',
|
||||
'descrip' => $item['descrip'],
|
||||
'status_cn' => $item['status'] ? '已支付' : '未支付',
|
||||
];
|
||||
}
|
||||
}
|
||||
$sum = $this->app_liche_orders_model->sum('total_price', ['o_id'=>$params['id'],'status'=>1,'pay_price!='=>0]);
|
||||
$sum = $this->app_liche_orders_model->sum('total_price', ['o_id'=>$params['id'],'status'=>1,'pay_price>'=>0]);
|
||||
$this->data['pay_price'] = $sum['total_price'];
|
||||
$this->data['need_price'] = $this->orders_entity->recevable_price($params['id']);
|
||||
$this->data['list'] = $list;
|
||||
@@ -796,21 +793,26 @@ class Orders extends HD_Controller
|
||||
//添加支付日志
|
||||
public function add_paylog()
|
||||
{
|
||||
$id = $this->input->get_post('id');
|
||||
$row = $this->orders_model->get(['id' => $id]);
|
||||
$srv_price = $this->orders_entity->order_srv_money($row['id']);
|
||||
if ($this->input->method() == 'post') {
|
||||
$id = $this->input->post('id');
|
||||
$row = $this->orders_model->get(['id' => $id]);
|
||||
$money = $this->input->post('money');
|
||||
$pay_time = $this->input->post('pay_time');
|
||||
$wx_mchid = $this->input->post('wx_mchid');
|
||||
$descrip = $this->input->post('descrip');
|
||||
$type = $this->input->post('type');
|
||||
if (!$money || !$pay_time || !$row || !$wx_mchid) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '参数错误');
|
||||
}
|
||||
$p_row = $this->app_liche_orders_model->get(['pid'=>0,'o_id'=>$row['id']]);
|
||||
$this->load->helper('order');
|
||||
$sid = create_order_no(350200, 'liche', 1, 5);
|
||||
$sid = create_order_no(350200, 'liche', 1, $type);
|
||||
$data = [
|
||||
'o_id' => $row['id'],
|
||||
'sid' => $sid,
|
||||
'uid' => $p_row['uid'],
|
||||
'entrust_uid' => $p_row['entrust_uid'],
|
||||
'mch_id' => $wx_mchid,
|
||||
'brand_id' => $row['brand_id'],
|
||||
's_id' => $row['s_id'],
|
||||
@@ -819,19 +821,55 @@ class Orders extends HD_Controller
|
||||
'incor_id' => $row['incor_id'],
|
||||
'total_price' => $money,
|
||||
'pay_price' => $money,
|
||||
'type' => 5,
|
||||
'status' => 1,
|
||||
'pay_time' => date('Y-m-d H:i:s', strtotime($pay_time)),
|
||||
'type' => $type,
|
||||
'status' => 0,
|
||||
'c_time' => time()
|
||||
];
|
||||
$descrip && $data['descrip'] = $descrip;
|
||||
if($type==1){ //定金
|
||||
$data['pid'] = $p_row['id'];
|
||||
$this->app_liche_orders_model->update(['status'=>-1],['type'=>1,'status'=>0,'o_id'=>$row['id']]);
|
||||
}elseif($type==2){ //服务费
|
||||
if(!$srv_price){
|
||||
return $this->show_json(SYS_CODE_FAIL, '该订单不需要支付服务费');
|
||||
}
|
||||
$this->app_liche_orders_model->update(['status'=>-1],['type'=>2,'status'=>0,'o_id'=>$row['id']]);
|
||||
$data['pid'] = $p_row['id'];
|
||||
}elseif($type==3){ //尾款
|
||||
$last_p_row = $this->app_liche_orders_model->get(['type'=>3,'pid'=>$p_row['id']]);
|
||||
if(!$last_p_row){
|
||||
return $this->show_json(SYS_CODE_FAIL, '该订单未到支付尾款阶段');
|
||||
}
|
||||
$data['pid'] = $last_p_row['id'];
|
||||
$this->app_liche_orders_model->update(['status'=>-1],['type'=>3,'status'=>0,'o_id'=>$row['id'],'pid'=>$last_p_row['id']]);
|
||||
//获取已支付尾款
|
||||
$pay_sum = $this->app_liche_orders_model->sum('pay_price',['type'=>3,'status'=>1,'o_id'=>$row['id'],'pid'=>$last_p_row['id']]);
|
||||
if($pay_sum['pay_price']+$money>$last_p_row['total_price']){
|
||||
return $this->show_json(SYS_CODE_FAIL, '请输入正确尾款金额');
|
||||
}
|
||||
}else{
|
||||
return $this->show_json(SYS_CODE_FAIL, '请选择正确订单类型');
|
||||
}
|
||||
$res = $this->app_liche_orders_model->add($data);
|
||||
if (!$res) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '保存失败');
|
||||
}
|
||||
$this->load->service('apporder/payment_service', array('app_id' => 1));
|
||||
$result = $this->payment_service->after_pay_liche($sid,$money,'',$pay_time);
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
||||
}
|
||||
$ck_row = $this->order_ckcars_model->get(['o_id'=>$id]);
|
||||
$sign_row = $this->order_signs_model->get(['o_id'=>$id]);
|
||||
$companys = $this->sys_company_model->select(['status' => 1, 'wx_mchid!=' => ''], 'id desc', '', '', 'id,wx_mchid,short');
|
||||
$type = [];
|
||||
if(!$row['status'] && $sign_row['status']==1){
|
||||
$type[] = ['id'=>1,'name'=>'定金'];
|
||||
}
|
||||
if($row['status']==2 && $ck_row['status']==2){
|
||||
$srv_price >0 && $type[] = ['id'=>2,'name'=>'服务费'];
|
||||
$type[] = ['id'=>3,'name'=>'尾款'];
|
||||
}
|
||||
$this->data['type'] = $type;
|
||||
$this->data['companys'] = $companys;
|
||||
$this->data['id'] = $this->input->get('id');
|
||||
return $this->show_view('receiver/orders/add_paylog');
|
||||
|
||||
@@ -8,6 +8,18 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">订单类型:</label>
|
||||
<div class="am-para-input w150">
|
||||
<select name="type">
|
||||
<option value="">请选择</option>
|
||||
<?foreach($type as $item){?>
|
||||
<option value="<?=$item['id']?>"><?=$item['name']?></option>
|
||||
<?}?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">收款公司:</label>
|
||||
<div class="am-para-input w150">
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
<th>收款公司</th>
|
||||
<th>备注</th>
|
||||
<th>付款时间</th>
|
||||
<th>支付状态</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -22,12 +20,6 @@
|
||||
<td>{{item.company}}</td>
|
||||
<td>{{item.descrip}}</td>
|
||||
<td>{{item.pay_time}}</td>
|
||||
<td>{{item.status_cn}}</td>
|
||||
<td>
|
||||
<button v-if="item.status==0" class="am-btn am-btn-primary am-btn-sm fl ml10" data-ajax="post" data-action="/app/liche/order/edit_pay" :data-params-id="item.id">
|
||||
确认线下收款
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -130,8 +130,9 @@ class Payment_service extends HD_Service{
|
||||
* @param string $sid
|
||||
* @param float $pay_price 订单真实支付金额
|
||||
* @param string $descrip 订单描述
|
||||
* @param date $pay_time 支付时间
|
||||
*/
|
||||
public function after_pay_liche($sid,$pay_price = '',$descrip=''){
|
||||
public function after_pay_liche($sid,$pay_price = '',$descrip='',$pay_time=''){
|
||||
if($sid){
|
||||
debug_log("[start] ". __FUNCTION__ . ": sid:".$sid, $this->log_file);
|
||||
$order = $this->app_liche_orders_model->get(array('sid'=>$sid));
|
||||
@@ -148,6 +149,7 @@ class Payment_service extends HD_Service{
|
||||
$upd = array('status'=>1,'pay_time'=>date('Y-m-d H:i:s'));
|
||||
$pay_price && $upd['pay_price'] = $pay_price;
|
||||
$descrip && $upd['descrip'] = $descrip;
|
||||
$pay_time && $upd['pay_time'] = $pay_time;
|
||||
$res = $this->app_liche_orders_model->update($upd,array('id'=>$order['id']));
|
||||
if($res) {
|
||||
//更新订单状态
|
||||
@@ -184,6 +186,7 @@ class Payment_service extends HD_Service{
|
||||
$upd = array('status'=>1,'pay_time'=>date('Y-m-d H:i:s'));
|
||||
$pay_price && $upd['pay_price'] = $pay_price;
|
||||
$descrip && $upd['descrip'] = $descrip;
|
||||
$pay_time && $upd['pay_time'] = $pay_time;
|
||||
$res = $this->app_liche_orders_model->update($upd,array('id'=>$order['id']));
|
||||
if($res){
|
||||
return array('code'=>1,'msg'=>'操作成功');
|
||||
@@ -195,6 +198,7 @@ class Payment_service extends HD_Service{
|
||||
$upd = array('status'=>1,'pay_time'=>date('Y-m-d H:i:s'));
|
||||
$pay_price && $upd['pay_price'] = $pay_price;
|
||||
$descrip && $upd['descrip'] = $descrip;
|
||||
$pay_time && $upd['pay_time'] = $pay_time;
|
||||
$res = $this->app_liche_orders_model->update($upd,array('id'=>$order['id']));
|
||||
if($res){
|
||||
//判断是否尾款支付完成
|
||||
@@ -221,6 +225,7 @@ class Payment_service extends HD_Service{
|
||||
$upd = array('status'=>1,'pay_time'=>date('Y-m-d H:i:s'));
|
||||
$pay_price && $upd['pay_price'] = $pay_price;
|
||||
$descrip && $upd['descrip'] = $descrip;
|
||||
$pay_time && $upd['pay_time'] = $pay_time;
|
||||
$res = $this->app_liche_orders_model->update($upd,array('id'=>$order['id']));
|
||||
if($res) {
|
||||
//更新订单下定时间
|
||||
|
||||
Reference in New Issue
Block a user