wangchuanjin 6 сар өмнө
parent
commit
bede9c7752

+ 4 - 4
openPower/config.json

@@ -1,8 +1,8 @@
 {
 {
-	"etcdAddr": ["192.168.3.206:2379"],
+	"etcdAddr": ["192.168.3.207:2379","192.168.3.165:2379","192.168.3.204:2379"],
 	"mongodb": {
 	"mongodb": {
 	    "main": {
 	    "main": {
-	      "address": "192.168.3.206:27080",
+	      "address": "192.168.3.149:27180",
 	      "size": 1,
 	      "size": 1,
 	      "dbName": "qfw"
 	      "dbName": "qfw"
 	    }
 	    }
@@ -10,12 +10,12 @@
   	"mysql": {
   	"mysql": {
     	"main": {
     	"main": {
 	      	"dbName": "jianyu",
 	      	"dbName": "jianyu",
-	 		"address" : "192.168.3.14:4000",
+	 		"address" : "192.168.3.217:4000",
 	      	"userName": "root",
 	      	"userName": "root",
 	      	"passWord": "=PDT49#80Z!RVv52_z",
 	      	"passWord": "=PDT49#80Z!RVv52_z",
 	      	"maxOpenConns": 2,
 	      	"maxOpenConns": 2,
 	      	"maxIdleConns": 2
 	      	"maxIdleConns": 2
 	    }
 	    }
   	},
   	},
-	"products": [14,15,16,17,18,19,20,22,23,24,27,28,25,26,29,30,31,32]
+	"products": [14,15,16,17,18,19,20,22,23,24,27,28,25,26,29,30,31,32,33,34,35]
 }
 }

+ 14 - 4
public/entity/base_power.go

@@ -144,12 +144,22 @@ func (b *base_power) OpenPower(goods_spec_id int64, appid, goods_code string, ac
 }
 }
 
 
 //取消权益
 //取消权益
-func (b *base_power) CancelPower(appid, goods_code string, spec_id, account_id, ent_account_id int64) bool {
+func (b *base_power) CancelPower(appid, goods_code string, spec_id, account_id, ent_account_id, ent_id int64) bool {
 	accountId := account_id
 	accountId := account_id
 	if accountId == 0 {
 	if accountId == 0 {
 		accountId = ent_account_id
 		accountId = ent_account_id
 	}
 	}
-	return Mysql_BaseService.UpdateOrDeleteBySql(`update base_power a inner join base_goods_spec_power b 
-		on (a.appid=? and a.account_id=? and a.status=1 and b.appid=? and b.goods_code=? and b.spec_id=? and a.goods_spec_power_id=b.id) 
-		set a.status=-1,update_time=?`, appid, accountId, appid, goods_code, spec_id, NowFormat(Date_Full_Layout)) > 0
+	return Mysql_BaseService.ExecTx("取消权益", func(tx *sql.Tx) bool {
+		nowFormat := NowFormat(Date_Full_Layout)
+		var r1 int64 = 1
+		if ent_id > 0 {
+			r1 = Mysql_BaseService.UpdateOrDeleteBySqlByTx(tx, `update base_ent_wait_empower a inner join base_goods_spec_power b 
+				on (a.appid=? and a.ent_id=? and a.end_time>? and b.appid=? and b.goods_code=? and b.spec_id=? and a.goods_spec_power_id=b.id) 
+				set a.end_time=?`, appid, ent_id, nowFormat, appid, goods_code, spec_id, nowFormat)
+		}
+		r2 := Mysql_BaseService.UpdateOrDeleteBySqlByTx(tx, `update base_power a inner join base_goods_spec_power b 
+			on (a.appid=? and a.account_id=? and a.status=1 and b.appid=? and b.goods_code=? and b.spec_id=? and a.goods_spec_power_id=b.id) 
+			set a.status=-1,a.update_time=?`, appid, accountId, appid, goods_code, spec_id, nowFormat)
+		return r1 > 0 || r2 > 0
+	})
 }
 }

+ 2 - 2
public/service/power.go

@@ -59,7 +59,7 @@ func OpenPower(appid, goods_code string, goods_spec_id, account_id, ent_account_
  * @param account_id 账户id
  * @param account_id 账户id
  * @return 是否成功
  * @return 是否成功
  */
  */
-func CancelPower(appid, goods_code string, goods_spec_id, account_id, ent_account_id int64) (bool, error) {
+func CancelPower(appid, goods_code string, goods_spec_id, account_id, ent_account_id, ent_id int64) (bool, error) {
 	if appid == "" {
 	if appid == "" {
 		return false, errors.New("无效的参数appid")
 		return false, errors.New("无效的参数appid")
 	} else if goods_code == "" {
 	} else if goods_code == "" {
@@ -67,7 +67,7 @@ func CancelPower(appid, goods_code string, goods_spec_id, account_id, ent_accoun
 	} else if account_id == 0 && ent_account_id == 0 {
 	} else if account_id == 0 && ent_account_id == 0 {
 		return false, errors.New("无效的参数account_id、ent_account_id")
 		return false, errors.New("无效的参数account_id、ent_account_id")
 	}
 	}
-	return Base_power.CancelPower(appid, goods_code, goods_spec_id, account_id, ent_account_id), nil
+	return Base_power.CancelPower(appid, goods_code, goods_spec_id, account_id, ent_account_id, ent_id), nil
 }
 }
 
 
 /*
 /*

+ 6 - 4
public/service/power_test.go

@@ -1,6 +1,7 @@
 package service
 package service
 
 
 import (
 import (
+	"log"
 	"testing"
 	"testing"
 
 
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/assert"
@@ -18,16 +19,16 @@ func TestOpenPower(t *testing.T) {
 
 
 func TestCancelPower(t *testing.T) {
 func TestCancelPower(t *testing.T) {
 	//信息发布
 	//信息发布
-	//b, err := CancelPower("10000", "xxfb_gyxx", 4, 11686)
+	//b, err := CancelPower("10000", "xxfb_gyxx", 4, 11686, 0)
 	//医疗领域化
 	//医疗领域化
-	b, err := CancelPower("10000", "lyh", 13, 13485, 0)
+	b, err := CancelPower("10000", "special_nosale_goods", 46, 0, 3, 1)
 	assert.Nil(t, err)
 	assert.Nil(t, err)
 	assert.True(t, b)
 	assert.True(t, b)
 }
 }
 
 
 func TestHasPowers(t *testing.T) {
 func TestHasPowers(t *testing.T) {
 	//企业
 	//企业
-	powers, err := HasPowers("10000", 180192, 12276, 221, 195)
+	powers, err := HasPowers("10000", 13496, 3, 1, 3870)
 	//个人
 	//个人
 	//powers, err := HasPowers("10000", 13485, 0, 0, 0)
 	//powers, err := HasPowers("10000", 13485, 0, 0, 0)
 	assert.Nil(t, err)
 	assert.Nil(t, err)
@@ -35,7 +36,8 @@ func TestHasPowers(t *testing.T) {
 }
 }
 
 
 func TestCfReEmpower(t *testing.T) {
 func TestCfReEmpower(t *testing.T) {
-	v, err := ReEmpower("10000", []string{"bi_dx_yjtj", "bi_dx_zxdx", "bi_dx_rcgl", "bi_dx_wjsgjkh", "bi_dx_shxs", "bi_dx_xszl"}, 1, []int64{3870, 123, 456})
+	v, err := ReEmpower("10000", []string{"bi_dx_yjtj", "bi_dx_zxdx", "bi_dx_rcgl", "bi_dx_wjsgjkh", "bi_dx_shxs", "bi_dx_xszl", "bi_dx_xsemx"}, 1, []int64{3870, 123, 456})
+	log.Println("--------", v)
 	assert.Nil(t, err)
 	assert.Nil(t, err)
 	assert.Equal(t, int64(1), v)
 	assert.Equal(t, int64(1), v)
 	//v, err = ReEmpower("10000", "znsj_jqr_use", 14184, []int64{4271})
 	//v, err = ReEmpower("10000", "znsj_jqr_use", 14184, []int64{4271})

+ 1 - 1
rpc/internal/logic/powerhandlelogic.go

@@ -35,7 +35,7 @@ func (l *PowerHandleLogic) PowerHandle(in *pb.PowerReq) (*pb.Resp, error) {
 		}
 		}
 	} else if in.Type == -1 { //取消
 	} else if in.Type == -1 { //取消
 		var ok bool
 		var ok bool
-		ok, err = CancelPower(in.Appid, in.GoodsCode, in.GoodsSpecId, in.AccountId, in.EntAccountId)
+		ok, err = CancelPower(in.Appid, in.GoodsCode, in.GoodsSpecId, in.AccountId, in.EntAccountId, in.EntId)
 		if ok {
 		if ok {
 			resp = &pb.Resp{Status: 1}
 			resp = &pb.Resp{Status: 1}
 		}
 		}