|
@@ -693,7 +693,7 @@ func refundAuto() {
|
|
|
isRenewalProtection := common.IntAll(v["is_renewal_protection"])
|
|
|
clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, "name,phone,company_nature,company_verification,cluename,userid,position_id,uid", "")
|
|
|
if clueData != nil && len(*clueData) > 0 {
|
|
|
- saleId = common.Int64All((*clueData)["position_id"])
|
|
|
+ saleId, _ = FindPositionIdClueId(clueId)
|
|
|
cluename = common.ObjToString((*clueData)["cluename"])
|
|
|
userName = gconv.String((*clueData)["name"])
|
|
|
company_nature = common.IntAll((*clueData)["company_nature"])
|
|
@@ -1332,7 +1332,8 @@ func CustomerChangeHandle(data map[string]interface{}) map[string]interface{} {
|
|
|
}
|
|
|
phone = common.ObjToString((*clueData)["phone"])
|
|
|
userName = gconv.String((*clueData)["name"])
|
|
|
- positionId := gconv.Int64((*clueData)["position_id"])
|
|
|
+ //positionId := gconv.Int64((*clueData)["position_id"])
|
|
|
+ positionId, _ := FindPositionIdClueId(clueId)
|
|
|
clueName = gconv.String((*clueData)["cluename"])
|
|
|
customData := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
@@ -1351,6 +1352,34 @@ func CustomerChangeHandle(data map[string]interface{}) map[string]interface{} {
|
|
|
"companyName": companyName,
|
|
|
}
|
|
|
}
|
|
|
+func FindPositionIdClueId(clueId int64) (int64, string) {
|
|
|
+ querySql := fmt.Sprintf(`
|
|
|
+SELECT
|
|
|
+ b.salesperson,c.position_id
|
|
|
+FROM
|
|
|
+ dwd_f_crm_clue_info a
|
|
|
+ INNER JOIN dwd_f_userbase_order_info b ON a.id = %d
|
|
|
+ AND a.uid = b.uid
|
|
|
+ AND (
|
|
|
+ b.payable_money > 0
|
|
|
+ OR (
|
|
|
+ b.payable_money = 0
|
|
|
+ AND ( b.filter LIKE "%分期付款补充权益%" OR b.filter LIKE "%原订单不支持开通多项权益%" OR b.filter LIKE "%权益码兑换%" )))
|
|
|
+ AND b.data_spec != "dhy4"
|
|
|
+ AND b.order_status = 1
|
|
|
+ AND ( b.refund_status != 1 OR b.refund_status IS NULL )
|
|
|
+ AND b.vip_starttime < "2099-01-01"
|
|
|
+ AND b.product_type IN ( "大会员", "企业商机管理" )
|
|
|
+ AND ( b.order_change = 0 OR ( b.order_change = 0 AND DATEDIFF( b.vip_endtime, b.vip_starttime )> 90 ) )
|
|
|
+ INNER JOIN dwd_f_crm_personnel_management c on c.ent_id =%d and b.salesperson=c.name
|
|
|
+ORDER BY
|
|
|
+ b.create_time,b.payable_money DESC limit 1`, clueId, db.EntId)
|
|
|
+ clueData := TiDb.SelectBySql(querySql)
|
|
|
+ if clueData == nil || len(*clueData) == 0 {
|
|
|
+ return 0, ""
|
|
|
+ }
|
|
|
+ return gconv.Int64((*clueData)[0]["position_id"]), gconv.String((*clueData)[0]["salesperson"])
|
|
|
+}
|
|
|
func refundAutoHistory() {
|
|
|
data := TiDb.Find("dwd_f_crm_clue_autodraw_record", nil, "", "", -1, -1)
|
|
|
if data != nil {
|