diff --git a/conf/app.conf b/conf/app.conf index c9ac13179..30bcd02c2 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -1,6 +1,6 @@ appname = jx-callback httpport = 8080 -runmode = dev +runmode = jxteam autorender = false copyrequestbody = true EnableDocs = true @@ -12,6 +12,13 @@ routinePoolSize = 1000 dadaAppKey = "dada154e2a41fd6cef3" dadaAppSecret = "7f97d8f258b70b450f04e7ab274ed8f8" +jdShopAccessToken = "de8157b447584885910f429011e49cb93yjq" +jdShopAppKey = "E1D746D42474D5F1F1A10CECE75D99F6" +jdShopAppSecret = "efa7e1d1a22640fa990e6cf164b28608" + +jcqAccessKey = "C0EB36912C652079DB111A922ACA406B" +jcqSecretKey = "86B6330051ECC88391E2630D34C2CA13" + mtwmAppID = "589" mtwmSecret = "a81eb3df418d83d6a1a4b7c572156d2f" mtwmCallbackURL = "http://callback.jxc4.com" @@ -132,345 +139,5 @@ smsNewUserOrderTemplate = "SMS_190284055" addEvent = true -[dev] -jdOrgCode = "320406" -jdToken = "77e703b7-7997-441b-a12a-2e522efb117a" -jdAppKey = "1dba76d40cac446ca500c0391a0b6c9d" -jdSecret = "a88d031a1e7b462cb1579f12e97fe7f4" +dbConnectStr = "root:Rosy@201507@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true" -jd2OrgCode = "349454" -jd2Token = "29e0e567-c475-433a-aff0-37176ee8d8a7" -jd2AppKey = "7fb947624ff847ae94ff2f068cc99652" -jd2Secret = "1097abd7ef09427099b4922784af123a" - -jd3OrgCode = "359459" -jd3Token = "5e2c0a60-4450-40c0-a1da-b560051251ea" -jd3AppKey = "21b627c23ea04c69b64b48d0b361213e" -jd3Secret = "51cd27a748e64c829b4b7f83f4844610" - -elmIsProd = false -elmToken = "2d2b583447b04b6bba5a6f3faed3559b" -elmAppKey = "RwT214gAsS" -elmSecret = "56afff4b9ebd8a7eb532d18fa33f17be57f9b9db" - -ebaiSource = "34665" -ebaiSecret = "c3db75b754ea2d89" - -mtpsAppKey = "25e816550bc9484480642f19a95f13fd" -mtpsSecret = "r4$HqrKx9~=7?2Jfo,$Z~a7%~k!Au&pEdI2)oPJvSbH2ao@2N0[8wSIvtuumh_J^" - -dadaIsProd = false -dadaCallbackURL = "http://callback.test.jxc4.com/dadadelivery/msg" -dadaSourceID = "73753" - -weixinAppID = "wxbf235770edaabc5c" -weixinSecret = "ba32b269a068a5b72486a0beafd171e8" -weixinToken = "17_roSCZgkCxhRnyFVtei0KdfHwdGP8PmLzJFhCieka4_X4_d-lgfaTxF6oIS6FE5lkgLbrtstSsO6HyDNHKsHJmpB8YOtJYN4sO-AezdWLF78M2phL0K8xCRjB9YE9-Ci64GCqS50o6LcVqux8ORVbACAFIM" - -dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true" - -getWeixinTokenURL = "http://www.jxc4.com/v2/sys/GetWXToken" -getYLYTokenURL = "http://www.jxc4.com/v2/sys/GetYLYToken" - -[prod] -EnableDocs = false - -jdOrgCode = "320406" -jdLoginName = "jd_jxcs1223" -jdToken = "29afd5a8-f93f-4d4c-9fce-a7297340af59" -jdAppKey = "1dba76d40cac446ca500c0391a0b6c9d" -jdSecret = "a88d031a1e7b462cb1579f12e97fe7f4" - -jd2OrgCode = "349454" -jd2Token = "29e0e567-c475-433a-aff0-37176ee8d8a7" -jd2AppKey = "7fb947624ff847ae94ff2f068cc99652" -jd2Secret = "1097abd7ef09427099b4922784af123a" - -jd3OrgCode = "359459" -jd3Token = "5e2c0a60-4450-40c0-a1da-b560051251ea" -jd3AppKey = "21b627c23ea04c69b64b48d0b361213e" -jd3Secret = "51cd27a748e64c829b4b7f83f4844610" - -jdEclpAccessToken = "bcb6201b5b3c45a0976dcda5e2dea8aejiwm" -jdEclpAppKey = "0D397F05CF11C51BCDCC81744680EBC3" -jdEclpAppSecret = "f16a5e57ff4f4f428b702c40d2d4b933" - -jdShopAccessToken = "de8157b447584885910f429011e49cb93yjq" -jdShopAppKey = "E1D746D42474D5F1F1A10CECE75D99F6" -jdShopAppSecret = "efa7e1d1a22640fa990e6cf164b28608" -jdsCookie = "shshshfpa=13b38d4a-8ba0-df12-0012-82d9a37fb835-1573795914; shshshfpb=abYp8Dq5JobRtp2pkZa7MbA%3D%3D; __jdu=1142616513; pinId=WMIzMhF5BfL6nJp9AcA2-A; pin=shop_jxcs; unick=shop_jxcs; _tp=7FBEvLyPe%2FKcgxsfY5lRgA%3D%3D; _pst=shop_jxcs; areaId=22; ipLoc-djd=22-1930-50948-57092; user-key=3ec204b4-f204-4320-98e3-b2569c757800; cn=0; shshshfp=5d23828ee6ea3a33e1a58588db1713f8; 3AB9D23F7A4B3C9B=AK36FFYF5J6WMPRH7YTXMEX4CATHR6NAA3IQEESU2I33FEJRQ3DRLU4SZJYD2XGFLCFW43DHYP5HQKOMR4EFQSLKLA; navigation=[%22shop_jxcs%22]; __jdv=122270672|baidu|-|organic|not set|1589514011252; language=zh_CN; ceshi3.com=000; csrf_token=b84d0a5c-6288-4db4-84e1-cadf66be3bf7; mba_muid=1142616513; TrackID=1qvZk-6QSAOp1NmaouJGEx58_cFglCFv57HEfoHOezMrOnV3_FSK-5ExeYhHx97IltBADG3dvJqLIt3P57wyUW4Z2Q3Y8ITo8Cfdmlz3kykM; RT="z=1&dm=jd.com&si=mcot45862q&ss=kaf1rcqz&sl=2&tt=38t&ld=22qx&nu=b99e5a7f32b36f184614d34a1d926a39&cl=3clu&ul=3crs&hd=3cz3"; b-sec=S2JWP6CAFP7K4I6PXVBUVCO6YVXUX2JAPDHLX5RZUDE4YKCGOEXJIINB3Q4THCFCMVWZPFAYGLWLG; thor=80FAF09E9A09B6E618A68057BDFCFCB8C86E8252DC9F7D3B34572625904FBA0AB6BF053A5325612EC0407791BB05F5301356E71E8B282C40C06D0B5DF3439DEECB102A78FAFF7AC0FC4E2D1FA8DD8BBAE1A011E50B5C74F1870AD982D7BF453F470F31F2241B73AC4C25485025C2ABEBC8A538AF7257824D2FAEE300A1435175B0B451FB5C19B78D729FC83152CA3BAF; _vender_=TNK3O6PALVQGGA33SGBIUTOKL4OOE6DP6OMNVIPMAMULGTRFWUMTVWGFRUTYP4L4EPN3KP73P33BOBN5SNJFBNQB5OMQYSJ5MORGQLJS7QAPOMIN7AZD6B3ZLP2DV4JCXDI5P3KOXJ3PHLIIRZ2YVS4JSSA3JRSBACNLJSC24ELO46GIMRW53XGW36EBPLZMZP2MQCAMJNO44FKT46B7VDVT7KQTELESOOF6E377AYC3NWKQF6ICIYBW4BA4JL5QG2NHGNOHOUJDNUW3N22UF32DLFLEIQGVO2W55J6AKPPBT227XA5NO4S3NFVIUUUADGOYH56T72MTNXCILWVMN4RMUNVFMGL4ISGXJS7YILE7A2ESPAU43MISAOZM2BR53MGRB5OZSQZPV5DBDCN2OVVT3XT5N2VMFELARQNTMAJCDBGXFURSN2Q7SYULLKZEZHTYWWOI65LS5OIHLUZQKWFGMNSQF2UBSYV7FG46CWJGMVHOGV3FY4RUEVJK6BQ223QK3H3VMTHXCZOZV4GKR5EWGIZZDVUAK4B36BPA5HPBO7PXKBOEXEBX77IYBNQLCGMK72J4VKNOUPYKNB5JE5D5UN3R2MMFGLJARTL2QTC5ZRZ4PJCJZWWOV37VWLWFVAN5IGHPAYME73KTNFABM5W73XLOXJFQWTFRZEK3FCL3BLRV4UOXLBQGA34R4WUBYSZURMKTXXB7U; __jda=65775340.1142616513.1573036516.1589946171.1589952725.54; __jdb=65775340.147.1142616513|54.1589952725; __jdc=65775340; _base_=YKH2KDFHMOZBLCUV7NSRBWQUJPBI7JIMU5R3EFJ5UDHJ5LCU7R2NILKK5UJ6GLA2RGYT464UKXAI4Z6HPCTN4UQM3WHVQ4ENFP57OC2DC7JQLRXRUO5PW6B77O6UXAZ4TCNE6YVKRXISVLBYGYO44RCDDPWDA4AEL7ZLXI2SG4SOQWCP5WPWO6EFS7HEHMRWVKBRVHB33TFD4SMNBHRJCTDFHU6SZXCZD6RFXX2OORYGL5H2GYF2IIH2KKD4T72IR4F577G2E5II2OMMXYF2GDYNTS7WGAUXFEWRJ3CTKDBDWMHUKJQF4ZFOTNBBYBIZRXZYERXXIG6ATJFKID7XOR3NQ2CL6K7A2IEZV5HCBNYDPXFCM2ZMCS474KZ44S5F; _vender_new_=GI63BGTJFDBQ46CD7JXUX3HEPM4P5LEA3TJTFGW4ZGGIVOLTPK5T25EXTBLCENPUTR7E2I23YDFQ4ARO6JW3NHSWBDE73RTUKJTADIPFPLYFE3ARGJUBPHWUIONS72KRQOZC5P7PB4VPPLRHGEP7L3Z5K62L2E2MGTWHFJRQ3CAVBDYVW2Z4J6U73HW4BKKOCDAH5T6OJJKWKLBZFOTI7342QSL7YQ2E3I4T777RNZF23XGOTCP3D4INHNO5MNKT3XJZQBVHWUVZYQUXCK5QQTKWADKQUCYV3JRY6YAYOD7Z5IIKGNLREQTCPO7SYGSIS655JUGOUILFLXVZE6KCFG7ZTPRUD6VPE4KCIE4OUZSED6FTSEZHTM363E7XXCHB4NA7VLZHCQSBHDVGMRA7RM4RGJC3MOI4TJNGCLW6QKUCCZAY7XTGOTMC53TFUYERGNIH2RBULZ7UTZH5GU3TC6RWFI2QL4QTAIARA6GNVXENEOYIPZEHN222YDAJX5OBBEECAMAPNKZ3XNF5CNGDJ3DSU2ZLOCAKLFPCYTIIWPPJMCQ636F5464HS4OVFPFNIDW4OCE23JRPYP5FAL6TKHPAC3H3ZRU7WA5GKJJKBZUGIX7NEO4LZB7FJ3RZZZH3UHPQMNILD5DT2V7HVCUOVNOFBEOW5ID2ZMQ3XV264IU4MYHN64RA; _BELONG_CLIENT_=WPSC4XJXWK5USS4JNZY2X7VRLR5MCBKRSVHEXABGTHDGISIQK5YOLZUXYE7IOIM7MOKO74H6CRN6WHAAR4TMDV3XZWMXZRCRT5XRNE3V356BTOB2Y7LPK66VWQK6HPTGWVXIDXDCPVE3W5WMHAIO6AT2LX2XXVNUCXR34ZWFK6HY45CORGIKOSYDYZBF27WOKTUX6BS4FZMIJWNUX6CB4JAA25ZLF7ZEKYOO4QV5HTSBXGNRM3E242MBI6V5D4C5VJDQ3EOYCOW5BMTUJZACIBHXQFAVLRF76VQY5PNJGGJNBEZHSFYYJA3YORRT7FB5AHCOIFQKF3W5RWNUX6CB4JAA26JNMO7AYWNUPZF5HTSBXGNRM3E242MBI6V5D4C5VJDQ3EOYCOW5BWZDKMOJ5BS6II53ERY6ALV3ZWPF42L4CPUHEGPYIII35KDC4FCNVCORCXFD6IVNLBEDPB2GGP4UHWNRUDOQBDIW7RZJXBA2WV5ANZOTEGUCDWYRVQS2YUTIZNZ276PRYG4N56V6YTII7MBKBC7LYHO7C555HTSBXGNRM3E466AYN67DHWVM5HQFJ4NFDO5BTOKMOS5L2CXFVYDR2FCOILVYPEI; _lvtc_=5ZH3OJ7CWYNVGEKDRC32XTFXGY" - -elmIsProd = true -elmToken = "" -elmAppKey = "KLRDcOZGrk" -elmSecret = "1fc221f8265506531da36fb613d5f5ad673f2e9a" - -ebaiSource = "34665" -ebaiSecret = "c3db75b754ea2d89" - -mtpsAppKey = "3c0a05d464c247c19d7ec13accc78605" -mtpsSecret = "b1M}9?:sTbsB[OF2gNORnN(|(iy9rB8(`7]|[wGLnbmt`evfM>E:A90DjHAW:UPE" - -dadaIsProd = true -dadaCallbackURL = "http://callback.jxc4.com/dadadelivery/msg" -dadaSourceID = "6660" - -weixinAppID = "wx2bb99eb5d2c9b82c" -weixinSecret = "6bbbed1443cc062c20a015a64c07a531" -weixinMiniAppID2 = "wx4b5930c13f8b1170" -weixinMiniSecret2 = "2a57228a716ce991a52739f0ff41111d" -weixinMiniAppID3 = "wx18111a41fd17f24f" -weixinMiniSecret3 = "c79ac6e1b2d6d7968e72a9658a8b6715" - -yinbaoAppKey = "682628966212343269" -yinbaoAppID = "18C0E0867E467DBC26EFF5E957B02EC4" - -aliUpcAppCode = "00a6eefba0204d3fa310ac0ee7a6fc54" - -wxpayNotifyURL = "http://callback.jxc4.com/wxpay/msg/" - -tonglianPayAppID = "00183083" -tonglianPayKey = "18048531223" -tonglianPayCusID = "56065105499TVAH" -tonglianPayNotifyURL = "http://callback.jxc4.com/tonglian/msg/" - -dbConnectStr = "root:WebServer@1@tcp(db1.int.jxc4.com:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true" - -enableStoreWrite = true -enableJdStoreWrite = true -enableEbaiStoreWrite = true -enableMtwmStoreWrite = true -enableWscStoreWrite = true -enableYbStoreWrite = true -enableJdShopWrite = true - -disableWeimob = false -weimobCallbackURL = "http://callback.jxc4.com/weimob" - -dingdingAgentID = 239461075 -dingdingAppKey = "ding7iu9cptairtcls0c" -dingdingSecret = "LWrZAFeqUfuVv7n_tc8vPpCAx6PT4CwManx2XCVhJOqGsx2L5XCDuX1sAN_JtvsI" - -dingdingCallbackURL = "http://callback.jxc4.com/dingding/msg" - -pushAppID = "5lyyrvHODG6wC8Sdr3a9h" -pushAppKey = "iFrkUDmR2g5eqQpfh2kQ57" -pushAppSecret = "WTn53qd6WAAdLMXfmXvzb7" -pushMasterSecret= "dGZcR0XGGg7H5Pd7FR3n47" - -[jxgy] -httpport = 8088 -EnableDocs = false - -dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxgy?charset=utf8mb4&loc=Local&parseTime=true" - -jdOrgCode = "339032" -jdLoginName = "jd_jxgy" -jdToken = "c45e6510-00ba-4be2-977e-bcb9c9792cc7" -jdAppKey = "5d5577a2506f41b8b4ec520ba83490f5" -jdSecret = "0b01b9eeb15b41dab1c3d05d95c17a26" -jdStorePageCookie = "YDYCWYUGKSROMV3MKJQIFINJ5CLPYH6IRVFUMFJD3JI6VQKHX3YPHTWDIDBNMCBUKSY3P7SKAHHKR7PHQDSFRXZEWXA4XOUTALIQDGDYIEUCMDPWSYGDVT42DJ27CD27QKCR3UN7KF7EPIHGPR7GCRTBD5YGNZW4AIACY4HXDMCETEWCPFKOTM4HRJBSMMQJ77SR62PYMP6RCG33IRQGP6PRCKAO4M7FUA7G2ZM2SFQ6F6WUNO5GXDJSVUELLBJT" - -ebaiSource = "35957" -ebaiSecret = "10013fbb7c2ddad7" -ebaiStorePageCookieWMUSS = "AIgAAABBA3NOWA8IckAGYixvPUR0K1s5EhVyCwsoVlRxCFlPSFtCFzRQHiYRIwg9BRPgwAAE0UBCHBcQQJwMw17WmJQTGoqGzMGXEo5LWhePQxmeR4reiYcV2YdSBkqRHMNFD92PVkqQjZze2JbWR9mQBkFaxMrB2kRBCmHC1FNXg6wdesOxNgDAAGs9ZB0A" -ebaiStorePageCookieWMSTOKEN = "QAAGALAAAFd2VaeBVCNBtlDTJUL2NXW2YFIiBzMWksCWFWQRCGlESI_2QAABmRgRwSFsGfRsPhJLuCgHL_g6HUAAAUuy3E2_vQhVHAQAAdPYKHHEB0Rpg_foY_bcAAgB" - -mtwmAppID = "4123" -mtwmSecret = "df2c88338b85f830cebce2a9eab56628" -mtwmCallbackURL = "http://callback-jxgy.jxc4.com" -mtwmCookieStr = "_lxsdk_cuid=16f413bd94fc8-0daccb808f461b-1d336b5a-13c680-16f413bd94fc8; _lxsdk=16f413bd94fc8-0daccb808f461b-1d336b5a-13c680-16f413bd94fc8; uuid=d1e8adb3d2774b89fe6e.1577347439.1.0.0; uuid_update=true; wpush_server_url=wss://wpush.meituan.com; acctId=62884810; token=0LhaIAAgrL1Hy0DDATjZqt4lRHauN_bBL3q0AvxUFUWo*; brandId=-1; wmPoiId=-1; isOfflineSelfOpen=0; city_id=0; isChain=1; existBrandPoi=true; ignore_set_router_proxy=true; region_id=; region_version=0; newCategory=false; bsid=SUVq2IfzZ53EHaTVoCE3UsmKkH5ZevxTjkwpNcaLKkbUOBkEyuZp8mPFwhgqkxsCGNjZILNj5aV8uVSQc888bg; device_uuid=!625e0297-431a-49ad-8b18-a0562c38a8eb; cityId=510100; provinceId=510000; city_location_id=0; location_id=0; pushToken=0LhaIAAgrL1Hy0DDATjZqt4lRHauN_bBL3q0AvxUFUWo*; set_info=%7B%22wmPoiId%22%3A-1%2C%22ignoreSetRouterProxy%22%3Atrue%7D; igateApp=shangouepc; LX_SC_CONSTANT=c_nehoktcu; shopCategory=food; JSESSIONID=unlrbu07lvm2s734eyedxr0j; _lxsdk_s=16f413bd950-189-8bb-8df%7C%7C33" - -enableStoreWrite = true -enableJdStoreWrite = true -enableEbaiStoreWrite = true -enableMtwmStoreWrite = true -enableYbStoreWrite = true -enableJdShopWrite = true - -mtpsAppKey = "3c0a05d464c247c19d7ec13accc78605" -mtpsSecret = "b1M}9?:sTbsB[OF2gNORnN(|(iy9rB8(`7]|[wGLnbmt`evfM>E:A90DjHAW:UPE" - -dadaIsProd = true -dadaCallbackURL = "http://callback-jxgy.jxc4.com/dadadelivery/msg" -dadaSourceID = "6660" - -weixinAppID = "wx2bb99eb5d2c9b82c" -weixinSecret = "6bbbed1443cc062c20a015a64c07a531" - -weixinMiniAppID = "wx2d6949f724b2541d" -weixinMiniSecret = "11f3c380551c4683c149990b004d6df9" - -weixinMiniAppID2 = "wx4b5930c13f8b1170" -weixinMiniSecret2 = "2a57228a716ce991a52739f0ff41111d" - -wxpayNotifyURL = "http://callback-jxgy.jxc4.com/wxpay/msg/" - -tonglianPayAppID = "00183083" -tonglianPayKey = "18048531223" -tonglianPayCusID = "56065105499TVAH" -tonglianPayNotifyURL = "http://callback-jxgy.jxc4.com/tonglian/msg/" - -backstageHost = "http://www-jxgy.jxc4.com" -wxBackstageHost = "http://wx-jxgy.jxc4.com" - -dingdingAgentID = 258707199 -dingdingAppKey = "dingtozhutfr98qgwc7d" -dingdingSecret = "7EJ0HDbkxQri-O2RSaYUu7_ZwvvMKtRVHT8cpyfvIvK6A9n9HRwPNCNRJFuEDeT_" - -dingdingQRCodeAppKey = "dingoaw990o1jm9jswvwib" -dingdingQRCodeSecret = "N9dyC9qB84sauQPs4_JYrILMsG5Krqm9-PSSVJ8t9hb87rrHiFUirISxGF5G57RV" - -dingdingCallbackURL = "http://callback-jxgy.jxc4.com/dingding/msg" - -getWeixinTokenURL = "http://www.jxc4.com/v2/sys/GetWXToken" -getYLYTokenURL = "http://www.jxc4.com/v2/sys/GetYLYToken" -getPushTokenURL = "http://www.jxc4.com/v2/sys/GetPushToken" - -jdEclpAccessToken = "bcb6201b5b3c45a0976dcda5e2dea8aejiwm" -jdEclpAppKey = "0D397F05CF11C51BCDCC81744680EBC3" -jdEclpAppSecret = "f16a5e57ff4f4f428b702c40d2d4b933" - -jdShopAccessToken = "de8157b447584885910f429011e49cb93yjq" -jdShopAppKey = "E1D746D42474D5F1F1A10CECE75D99F6" -jdShopAppSecret = "efa7e1d1a22640fa990e6cf164b28608" - -storeName = "京西果园" - -[test] -jdOrgCode = "82029" -jdToken = "594ab45a-9a73-4a43-82b0-a64cbd55d883" -jdAppKey = "06692746f7224695ad4788ce340bc854" -jdSecret = "d6b42a35a7414a5490d811654d745c84" - -elmIsProd = false -elmToken = "2d2b583447b04b6bba5a6f3faed3559b" -elmAppKey = "RwT214gAsS" -elmSecret = "56afff4b9ebd8a7eb532d18fa33f17be57f9b9db" - -ebaiSource = "62923" -ebaiSecret = "aa4cdc6c1108486b" - -mtpsAppKey = "25e816550bc9484480642f19a95f13fd" -mtpsSecret = "r4$HqrKx9~=7?2Jfo,$Z~a7%~k!Au&pEdI2)oPJvSbH2ao@2N0[8wSIvtuumh_J^" - -dadaIsProd = false -dadaCallbackURL = "http://callback.test.jxc4.com/dadadelivery/msg" -dadaSourceID = "73753" - -weixinAppID = "wxbf235770edaabc5c" -weixinSecret = "ba32b269a068a5b72486a0beafd171e8" - -dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true" - -[alpha] -httpport = 8088 - -# xiaan -jdOrgCode = "82029" -jdToken = "594ab45a-9a73-4a43-82b0-a64cbd55d883" -jdAppKey = "06692746f7224695ad4788ce340bc854" -jdSecret = "d6b42a35a7414a5490d811654d745c84" -jdStorePageCookie = "5EOCZRXVCRXBTYD5EPV6FOXRCQWFFQO75FRMJ3BAKZ5JXY6XTJECMWXK5OZIPLZTUWZKZKXHXA6I7G3WMIKSWOHZIHRLNE5FZY3NBD6G5IMBOYHMJSJR3RF4TMZB2JEW2DF755YPFUSA6BMWI3KNLT3I4EAP2Z4JA6ZWAA34MNQX5P6LOI4EGG76QJU3G3VW7QFE6BAVAONMKBEHKNXNZGX3RQF7PHXDXSPJSY5XQEGM7IV2L7LKIG3M2D6QVSPEGQW4NV7SZ4TX32D2XQA7PIX46M" - -ebaiSource = "61219" -ebaiSecret = "9ef8be6a53fb33e7" -ebaiStorePageCookieWMUSS = "AHYHAAApIX5oBXUFKFsXKEdObiclRUhTFRZ1MUh7KEMiClB7MnB5G3VvIB5KN0USAABjQ4KngBfQ4Wcj9ebWYiEHBxCyNiBT1Yc111PhQ7UBluCENnCUB0HjIzfCAaHjAKEDoscT8sDL8JDDuQD81NaQ1dW3kN1MS9DeFMPgwC2YYROVy7AV3cKhMPkQrBwA" -ebaiStorePageCookieWMSTOKEN = "UAABRL3ZhLykdGFQBBDxXVDBuYisaB3tQHjUmHlQ5cEAs5dxMdG0R-EwVILAy_CV1Vlw_nbQAA0ijuEe-F2xUzAQAAAdujHKzhohkrxY0c5LsAAH0CeSGnywAHBQAAMA" - -mtwmCookieStr = "_lxsdk_cuid=169b7bc1b9fc8-05092471a96611-12376d51-1fa400-169b7bc1b9fc8; _lxsdk=169b7bc1b9fc8-05092471a96611-12376d51-1fa400-169b7bc1b9fc8; uuid=7a6a1345b4a3f7aa5f81.1553565752.1.0.0; _ga=GA1.2.285163436.1559264188; uuid_update=true; pushToken=0sz3wYPQoNug6okzOjEacuvrEWGRhuv6gL5ZWX98prCw*; device_uuid=!88124822-2b68-4425-865d-a3ffffe355af; wpush_server_url=wss://wpush.meituan.com; acctId=26535718; token=0vt6ufSF1X8GXpVq3N5zhE5FhcgONSuNTg4LiqkqEyTM*; brandId=-1; wmPoiId=2523687; isOfflineSelfOpen=0; city_id=999999; isChain=0; existBrandPoi=false; ignore_set_router_proxy=false; region_id=2000000001; region_version=1522820107; newCategory=false; bsid=g54gdBCxg9fu4t99gGLf770bFzBT_eUQXA3_FWLgDeCWrEtsNdXkJtckKTvMEthURtXVg_j0mhDauKPgDUgZyQ; cityId=510100; provinceId=510000; city_location_id=10000004; location_id=10000005; set_info=%7B%22wmPoiId%22%3A2523687%2C%22region_id%22%3A%222000000001%22%2C%22region_version%22%3A1522820107%7D; igateApp=shangouepc; shopCategory=market; LX_SC_CONSTANT=c_nehoktcu; JSESSIONID=43y9tjdcnjh2kojf6qfehvdy; _lxsdk_s=16f4145a84c-d6a-c22-64c%7C%7C19" - -mtpsAppKey = "25e816550bc9484480642f19a95f13fd" -mtpsSecret = "r4$HqrKx9~=7?2Jfo,$Z~a7%~k!Au&pEdI2)oPJvSbH2ao@2N0[8wSIvtuumh_J^" - -dadaIsProd = false -dadaCallbackURL = "http://callback.alpha.jxc4.com/dadadelivery/msg" -dadaSourceID = "73753" - -weixinAppID = "wx2bb99eb5d2c9b82c" -weixinSecret = "6bbbed1443cc062c20a015a64c07a531" -getWeixinTokenURL = "http://www.jxc4.com/v2/sys/GetWXToken" -getWeixin2TokenURL = "http://www.jxc4.com/v2/sys/GetWX2Token" -weixinMiniAppID2 = "wx4b5930c13f8b1170" -weixinMiniSecret2 = "2a57228a716ce991a52739f0ff41111d" - -mtwmCallbackURL = "http://callback.alpha.jxc4.com" - -dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxstore_alpha?charset=utf8mb4&loc=Local&parseTime=true" - -enableStoreWrite = true -enableJdStoreWrite = true -enableEbaiStoreWrite = true -enableMtwmStoreWrite = true -enableWscStoreWrite = false -enableYbStoreWrite = false - -[beta] -enableStoreWrite = true -enableJdStoreWrite = false -enableEbaiStoreWrite = false -enableElmStoreWrite = false -enableMtwmStoreWrite = false -enableWscStoreWrite = false -enableYbStoreWrite = false -enableJdShopWrite = false - -jdOrgCode = "320406" -jdLoginName = "jd_jxcs1223" -jdToken = "29afd5a8-f93f-4d4c-9fce-a7297340af59" -jdAppKey = "1dba76d40cac446ca500c0391a0b6c9d" -jdSecret = "a88d031a1e7b462cb1579f12e97fe7f4" - -jd2OrgCode = "349454" -jd2Token = "29e0e567-c475-433a-aff0-37176ee8d8a7" -jd2AppKey = "7fb947624ff847ae94ff2f068cc99652" -jd2Secret = "1097abd7ef09427099b4922784af123a" - -jd3OrgCode = "359459" -jd3Token = "5e2c0a60-4450-40c0-a1da-b560051251ea" -jd3AppKey = "21b627c23ea04c69b64b48d0b361213e" -jd3Secret = "51cd27a748e64c829b4b7f83f4844610" - -jdEclpAccessToken = "bcb6201b5b3c45a0976dcda5e2dea8aejiwm" -jdEclpAppKey = "0D397F05CF11C51BCDCC81744680EBC3" -jdEclpAppSecret = "f16a5e57ff4f4f428b702c40d2d4b933" - -jdShopAccessToken = "de8157b447584885910f429011e49cb93yjq" -jdShopAppKey = "E1D746D42474D5F1F1A10CECE75D99F6" -jdShopAppSecret = "efa7e1d1a22640fa990e6cf164b28608" -jdsCookie = "shshshfpa=13b38d4a-8ba0-df12-0012-82d9a37fb835-1573795914; shshshfpb=abYp8Dq5JobRtp2pkZa7MbA%3D%3D; __jdu=1142616513; pinId=WMIzMhF5BfL6nJp9AcA2-A; pin=shop_jxcs; unick=shop_jxcs; _tp=7FBEvLyPe%2FKcgxsfY5lRgA%3D%3D; _pst=shop_jxcs; areaId=22; ipLoc-djd=22-1930-50948-57092; user-key=3ec204b4-f204-4320-98e3-b2569c757800; cn=0; shshshfp=5d23828ee6ea3a33e1a58588db1713f8; 3AB9D23F7A4B3C9B=AK36FFYF5J6WMPRH7YTXMEX4CATHR6NAA3IQEESU2I33FEJRQ3DRLU4SZJYD2XGFLCFW43DHYP5HQKOMR4EFQSLKLA; navigation=[%22shop_jxcs%22]; __jdv=122270672|baidu|-|organic|not set|1589514011252; language=zh_CN; ceshi3.com=000; csrf_token=b84d0a5c-6288-4db4-84e1-cadf66be3bf7; mba_muid=1142616513; TrackID=1qvZk-6QSAOp1NmaouJGEx58_cFglCFv57HEfoHOezMrOnV3_FSK-5ExeYhHx97IltBADG3dvJqLIt3P57wyUW4Z2Q3Y8ITo8Cfdmlz3kykM; RT="z=1&dm=jd.com&si=mcot45862q&ss=kaf1rcqz&sl=2&tt=38t&ld=22qx&nu=b99e5a7f32b36f184614d34a1d926a39&cl=3clu&ul=3crs&hd=3cz3"; b-sec=S2JWP6CAFP7K4I6PXVBUVCO6YVXUX2JAPDHLX5RZUDE4YKCGOEXJIINB3Q4THCFCMVWZPFAYGLWLG; thor=80FAF09E9A09B6E618A68057BDFCFCB8C86E8252DC9F7D3B34572625904FBA0AB6BF053A5325612EC0407791BB05F5301356E71E8B282C40C06D0B5DF3439DEECB102A78FAFF7AC0FC4E2D1FA8DD8BBAE1A011E50B5C74F1870AD982D7BF453F470F31F2241B73AC4C25485025C2ABEBC8A538AF7257824D2FAEE300A1435175B0B451FB5C19B78D729FC83152CA3BAF; _vender_=TNK3O6PALVQGGA33SGBIUTOKL4OOE6DP6OMNVIPMAMULGTRFWUMTVWGFRUTYP4L4EPN3KP73P33BOBN5SNJFBNQB5OMQYSJ5MORGQLJS7QAPOMIN7AZD6B3ZLP2DV4JCXDI5P3KOXJ3PHLIIRZ2YVS4JSSA3JRSBACNLJSC24ELO46GIMRW53XGW36EBPLZMZP2MQCAMJNO44FKT46B7VDVT7KQTELESOOF6E377AYC3NWKQF6ICIYBW4BA4JL5QG2NHGNOHOUJDNUW3N22UF32DLFLEIQGVO2W55J6AKPPBT227XA5NO4S3NFVIUUUADGOYH56T72MTNXCILWVMN4RMUNVFMGL4ISGXJS7YILE7A2ESPAU43MISAOZM2BR53MGRB5OZSQZPV5DBDCN2OVVT3XT5N2VMFELARQNTMAJCDBGXFURSN2Q7SYULLKZEZHTYWWOI65LS5OIHLUZQKWFGMNSQF2UBSYV7FG46CWJGMVHOGV3FY4RUEVJK6BQ223QK3H3VMTHXCZOZV4GKR5EWGIZZDVUAK4B36BPA5HPBO7PXKBOEXEBX77IYBNQLCGMK72J4VKNOUPYKNB5JE5D5UN3R2MMFGLJARTL2QTC5ZRZ4PJCJZWWOV37VWLWFVAN5IGHPAYME73KTNFABM5W73XLOXJFQWTFRZEK3FCL3BLRV4UOXLBQGA34R4WUBYSZURMKTXXB7U; __jda=65775340.1142616513.1573036516.1589946171.1589952725.54; __jdb=65775340.147.1142616513|54.1589952725; __jdc=65775340; _base_=YKH2KDFHMOZBLCUV7NSRBWQUJPBI7JIMU5R3EFJ5UDHJ5LCU7R2NILKK5UJ6GLA2RGYT464UKXAI4Z6HPCTN4UQM3WHVQ4ENFP57OC2DC7JQLRXRUO5PW6B77O6UXAZ4TCNE6YVKRXISVLBYGYO44RCDDPWDA4AEL7ZLXI2SG4SOQWCP5WPWO6EFS7HEHMRWVKBRVHB33TFD4SMNBHRJCTDFHU6SZXCZD6RFXX2OORYGL5H2GYF2IIH2KKD4T72IR4F577G2E5II2OMMXYF2GDYNTS7WGAUXFEWRJ3CTKDBDWMHUKJQF4ZFOTNBBYBIZRXZYERXXIG6ATJFKID7XOR3NQ2CL6K7A2IEZV5HCBNYDPXFCM2ZMCS474KZ44S5F; _vender_new_=GI63BGTJFDBQ46CD7JXUX3HEPM4P5LEA3TJTFGW4ZGGIVOLTPK5T25EXTBLCENPUTR7E2I23YDFQ4ARO6JW3NHSWBDE73RTUKJTADIPFPLYFE3ARGJUBPHWUIONS72KRQOZC5P7PB4VPPLRHGEP7L3Z5K62L2E2MGTWHFJRQ3CAVBDYVW2Z4J6U73HW4BKKOCDAH5T6OJJKWKLBZFOTI7342QSL7YQ2E3I4T777RNZF23XGOTCP3D4INHNO5MNKT3XJZQBVHWUVZYQUXCK5QQTKWADKQUCYV3JRY6YAYOD7Z5IIKGNLREQTCPO7SYGSIS655JUGOUILFLXVZE6KCFG7ZTPRUD6VPE4KCIE4OUZSED6FTSEZHTM363E7XXCHB4NA7VLZHCQSBHDVGMRA7RM4RGJC3MOI4TJNGCLW6QKUCCZAY7XTGOTMC53TFUYERGNIH2RBULZ7UTZH5GU3TC6RWFI2QL4QTAIARA6GNVXENEOYIPZEHN222YDAJX5OBBEECAMAPNKZ3XNF5CNGDJ3DSU2ZLOCAKLFPCYTIIWPPJMCQ636F5464HS4OVFPFNIDW4OCE23JRPYP5FAL6TKHPAC3H3ZRU7WA5GKJJKBZUGIX7NEO4LZB7FJ3RZZZH3UHPQMNILD5DT2V7HVCUOVNOFBEOW5ID2ZMQ3XV264IU4MYHN64RA; _BELONG_CLIENT_=WPSC4XJXWK5USS4JNZY2X7VRLR5MCBKRSVHEXABGTHDGISIQK5YOLZUXYE7IOIM7MOKO74H6CRN6WHAAR4TMDV3XZWMXZRCRT5XRNE3V356BTOB2Y7LPK66VWQK6HPTGWVXIDXDCPVE3W5WMHAIO6AT2LX2XXVNUCXR34ZWFK6HY45CORGIKOSYDYZBF27WOKTUX6BS4FZMIJWNUX6CB4JAA25ZLF7ZEKYOO4QV5HTSBXGNRM3E242MBI6V5D4C5VJDQ3EOYCOW5BMTUJZACIBHXQFAVLRF76VQY5PNJGGJNBEZHSFYYJA3YORRT7FB5AHCOIFQKF3W5RWNUX6CB4JAA26JNMO7AYWNUPZF5HTSBXGNRM3E242MBI6V5D4C5VJDQ3EOYCOW5BWZDKMOJ5BS6II53ERY6ALV3ZWPF42L4CPUHEGPYIII35KDC4FCNVCORCXFD6IVNLBEDPB2GGP4UHWNRUDOQBDIW7RZJXBA2WV5ANZOTEGUCDWYRVQS2YUTIZNZ276PRYG4N56V6YTII7MBKBC7LYHO7C555HTSBXGNRM3E466AYN67DHWVM5HQFJ4NFDO5BTOKMOS5L2CXFVYDR2FCOILVYPEI; _lvtc_=5ZH3OJ7CWYNVGEKDRC32XTFXGY" - -elmIsProd = true -elmToken = "" -elmAppKey = "KLRDcOZGrk" -elmSecret = "1fc221f8265506531da36fb613d5f5ad673f2e9a" - -ebaiSource = "34665" -ebaiSecret = "c3db75b754ea2d89" - -mtpsAppKey = "3c0a05d464c247c19d7ec13accc78605" -mtpsSecret = "b1M}9?:sTbsB[OF2gNORnN(|(iy9rB8(`7]|[wGLnbmt`evfM>E:A90DjHAW:UPE" - -dadaIsProd = true -dadaCallbackURL = "http://callback.beta.jxc4.com/dadadelivery/msg" -dadaSourceID = "6660" - -weixinAppID = "wx2bb99eb5d2c9b82c" -weixinSecret = "6bbbed1443cc062c20a015a64c07a531" -weixinMiniAppID2 = "wx4b5930c13f8b1170" -weixinMiniSecret2 = "2a57228a716ce991a52739f0ff41111d" -weixinMiniAppID3 = "wx18111a41fd17f24f" -weixinMiniSecret3 = "c79ac6e1b2d6d7968e72a9658a8b6715" - -disableWeimob = false -getWeixinTokenURL = "http://www.jxc4.com/v2/sys/GetWXToken" -getWeixin2TokenURL = "http://www.jxc4.com/v2/sys/GetWX2Token" -getWeimobTokenURL = "http://www.jxc4.com/v2/sys/GetWeimobToken" -getPushTokenURL = "http://www.jxc4.com/v2/sys/GetPushToken" - -dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true" - -yinbaoAppKey = "682628966212343269" -yinbaoAppID = "18C0E0867E467DBC26EFF5E957B02EC4" - -aliUpcAppCode = "00a6eefba0204d3fa310ac0ee7a6fc54" diff --git a/controllers/act.go b/controllers/act.go deleted file mode 100644 index 89e6843a2..000000000 --- a/controllers/act.go +++ /dev/null @@ -1,381 +0,0 @@ -package controllers - -import ( - "fmt" - - "git.rosy.net.cn/jx-callback/business/jxstore/act" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/model/dao" - "github.com/astaxie/beego" -) - -type ActController struct { - beego.Controller -} - -// @Title 预创建活动 -// @Description 预创建活动 -// @Param token header string true "认证token" -// @Param name formData string true "活动名,必须唯一(所以名子上最好带上日期)" -// @Param type formData int true "活动类型,3:直降,4:秒杀(美团当前不支持秒杀)" -// @Param vendorIDs formData string true "厂商ID,当前只支持,京东:0,京西(用于记录活动信息):99" -// @Param beginAt formData string true "开始日期" -// @Param endAt formData string true "结束日期" -// @Param pricePercentage formData int true "活动价格比例" -// @Param advertising formData string true "广告语" -// @Param actStoreSkuList formData string true "活动门店商品信息" -// @Param overlapRule formData int false "活动重叠规则" -// @Param limitDaily formData int false "是否按日0-不限,>0限购单数(秒杀需填)" -// @Param limitUser formData int false "是否用户限购0-不限,1-限购" -// @Param limitCount formData int false "限购件数 0-不限,如账号限购、设备限购有一个为1,则限购件数必须大于0的整数" -// @Param remark formData string false "备注" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /PreCreateAct [post] -func (c *ActController) PreCreateAct() { - c.callPreCreateAct(func(params *tActPreCreateActParams) (retVal interface{}, errCode string, err error) { - var ( - vendorIDs []int - actStoreSkuList []*act.ActStoreSkuParam - ) - timeList, err := jxutils.BatchStr2Time(params.BeginAt, params.EndAt) - if err == nil { - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs, params.ActStoreSkuList, &actStoreSkuList); err == nil { - actObj := &model.Act{ - Name: params.Name, - Type: params.Type, - LimitUser: params.LimitUser, - LimitDaily: params.LimitDaily, - LimitCount: params.LimitCount, - OverlapRule: params.OverlapRule, - // Source:, - CreateType: model.ActCreateTypeAPI, - PricePercentage: params.PricePercentage, - BeginAt: timeList[0], - EndAt: timeList[1], - Advertising: params.Advertising, - Remark: params.Remark, - } - retVal, err = act.PreCreateAct(params.Ctx, actObj, vendorIDs, nil, actStoreSkuList) - } - } - return retVal, "", err - }) -} - -// @Title 创建活动 -// @Description 创建活动 -// @Param token header string true "认证token" -// @Param name formData string true "活动名,必须唯一(所以名子上最好带上日期)" -// @Param type formData int true "活动类型,3:直降,4:秒杀(美团当前不支持秒杀),5:折扣(京西)" -// @Param vendorIDs formData string true "厂商ID,当前只支持,京东:0,京西(用于记录活动信息):99" -// @Param vendorOrgCode formData string false "厂商内组织代码" -// @Param beginAt formData string true "开始日期" -// @Param endAt formData string true "结束日期" -// @Param pricePercentage formData int true "活动价格比例" -// @Param advertising formData string true "广告语" -// @Param actStoreSkuList formData string true "活动门店商品信息" -// @Param overlapRule formData int false "活动重叠规则" -// @Param discountType formData int false "折扣类型,当活动类型是折扣的时候传入" -// @Param discountValue1 formData int false "折扣一档" -// @Param discountValue2 formData int false "折扣二档" -// @Param limitDaily formData int false "是否按日0-不限,>0限购单数(秒杀需填)" -// @Param limitUser formData int false "是否用户限购0-不限,1-限购" -// @Param limitCount formData int false "限购件数 0-不限,如账号限购、设备限购有一个为1,则限购件数必须大于0的整数" -// @Param remark formData string false "备注" -// @Param isAsync formData bool false "是否异步,缺省否(暂时只支持同步)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateAct [post] -func (c *ActController) CreateAct() { - c.callCreateAct(func(params *tActCreateActParams) (retVal interface{}, errCode string, err error) { - var ( - vendorIDs []int - actStoreSkuList []*act.ActStoreSkuParam - ) - timeList, err := jxutils.BatchStr2Time(params.BeginAt, params.EndAt) - if err == nil { - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs, params.ActStoreSkuList, &actStoreSkuList); err == nil { - actObj := &model.Act{ - Name: params.Name, - Type: params.Type, - LimitUser: params.LimitUser, - LimitDaily: params.LimitDaily, - LimitCount: params.LimitCount, - OverlapRule: params.OverlapRule, - // Source:, - CreateType: model.ActCreateTypeAPI, - PricePercentage: params.PricePercentage, - BeginAt: timeList[0], - EndAt: timeList[1], - Advertising: params.Advertising, - Remark: params.Remark, - DiscountType: params.DiscountType, - DiscountValue1: params.DiscountValue1, - DiscountValue2: params.DiscountValue2, - } - retVal, err = act.CreateAct(params.Ctx, actObj, vendorIDs, params.VendorOrgCode, nil, actStoreSkuList, params.IsAsync) - } - } - return retVal, "", err - }) -} - -// @Title 查询活动 -// @Description 查询活动 -// @Param token header string true "认证token" -// @Param createdAtFrom query string false "创建开始日期" -// @Param createdAtTo query string false "创建结束日期" -// @Param keyword query string false "关键字" -// @Param actID query int false "活动id" -// @Param name query string false "活动名,不完全匹配" -// @Param cityCode query int false "活动门店所属城市code" -// @Param beginAt query string false "开始日期,包括" -// @Param endAt query string false "结束日期,包括" -// @Param vendorID query int false "包含平台" -// @Param typeList query string false "活动类型列表,3:直降,4:秒杀" -// @Param statusList query string false "活动状态列表" -// @Param createTypeList query string false "创建方式列表" -// @Param storeID query int false "包含门店" -// @Param skuID query int false "包含sku" -// @Param syncStatus query int false "活动同步标识,缺省不限制" -// @Param offset query int false "活动列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "活动列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /QueryActs [get] -func (c *ActController) QueryActs() { - c.callQueryActs(func(params *tActQueryActsParams) (retVal interface{}, errCode string, err error) { - timeList, err := jxutils.BatchStr2Time(params.CreatedAtFrom, params.CreatedAtTo, params.BeginAt, params.EndAt) - if err == nil { - var typeList, statusList, createTypeList []int - if err = jxutils.Strings2Objs(params.TypeList, &typeList, params.StatusList, &statusList, params.CreateTypeList, &createTypeList); err == nil { - if params.MapData["vendorID"] == nil { - params.VendorID = -1 - } - if params.MapData["syncStatus"] == nil { - params.SyncStatus = -1 - } - retVal, err = act.QueryActs(params.Ctx, params.ActID, params.Offset, params.PageSize, params.SyncStatus, params.Keyword, params.VendorID, - statusList, typeList, createTypeList, params.StoreID, params.SkuID, params.CityCode, timeList[2], timeList[3], timeList[0], timeList[1]) - } - } - return retVal, "", err - }) -} - -// @Title 取消活动 -// @Description 取消活动 -// @Param token header string true "认证token" -// @Param actID formData int true "活动id" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CancelAct [put] -func (c *ActController) CancelAct() { - c.callCancelAct(func(params *tActCancelActParams) (retVal interface{}, errCode string, err error) { - err = act.CancelAct(params.Ctx, params.ActID) - return retVal, "", err - }) -} - -// @Title 得到活动门店商品信息 -// @Description 得到活动门店商品信息 -// @Param token header string true "认证token" -// @Param actID query int true "活动id" -// @Param vendorIDs query string false "厂商ID列表" -// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)" -// @Param offset query int false "起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "表页大小(缺省全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetActStoreSkuInfo [get,post] -func (c *ActController) GetActStoreSkuInfo() { - c.callGetActStoreSkuInfo(func(params *tActGetActStoreSkuInfoParams) (retVal interface{}, errCode string, err error) { - var vendorIDs []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs); err == nil { - if params.PageSize == 0 { - params.PageSize = -1 - } - retVal, err = act.GetActStoreSkuInfo(params.Ctx, params.ActID, vendorIDs, params.Keyword, params.Offset, params.PageSize) - } - return retVal, "", err - }) -} - -// @Title 同步活动 -// @Description 同步活动 -// @Param token header string true "认证token" -// @Param actID formData int true "活动id" -// @Param vendorIDs formData string false "厂商ID列表" -// @Param isAsync formData bool false "是否异步" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncAct [put] -func (c *ActController) SyncAct() { - c.callSyncAct(func(params *tActSyncActParams) (retVal interface{}, errCode string, err error) { - var vendorIDs /*, storeIDs, skuIDs*/ []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs /*, params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs*/); err == nil { - retVal, err = act.SyncAct(params.Ctx, nil, params.ActID, vendorIDs, params.IsAsync) - } - return retVal, "", err - }) -} - -// @Title 添加SKU活动商品 -// @Description 添加SKU活动商品 -// @Param token header string true "认证token" -// @Param actID formData int true "活动id" -// @Param actStoreSkuAddList formData string false "需添加的活动商品信息" -// @Param actStoreSkuDeleteList formData string false "需删除的活动商品信息" -// @Param isAsync formData bool false "是否异步" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateActStoreSkuBind [put] -func (c *ActController) UpdateActStoreSkuBind() { - c.callUpdateActStoreSkuBind(func(params *tActUpdateActStoreSkuBindParams) (retVal interface{}, errCode string, err error) { - var actStoreSkuAddList, actStoreSkuDeleteList []*act.ActStoreSkuParam - if err = jxutils.Strings2Objs(params.ActStoreSkuAddList, &actStoreSkuAddList, params.ActStoreSkuDeleteList, &actStoreSkuDeleteList); err == nil { - if len(actStoreSkuAddList) == 0 && len(actStoreSkuDeleteList) == 0 { - err = fmt.Errorf("actStoreSkuAddList与actStoreSkuDeleteList不能都为空") - } else { - db := dao.GetDB() - dao.Begin(db) - func() { - defer func() { - if r := recover(); r != nil { - dao.Rollback(db) - } - }() - if len(actStoreSkuAddList) > 0 { - if err = act.AddActStoreSkuBind(params.Ctx, db, params.ActID, actStoreSkuAddList); err != nil { - dao.Rollback(db) - return - } - } - if len(actStoreSkuDeleteList) > 0 { - if _, err = act.DeleteActStoreSkuBind(params.Ctx, db, params.ActID, actStoreSkuDeleteList); err != nil { - dao.Rollback(db) - return - } - } - dao.Commit(db) - }() - if err == nil { - retVal, err = act.SyncAct(params.Ctx, nil, params.ActID, nil, params.IsAsync) - } - } - } - return retVal, "", err - }) -} - -// @Title 添加SKU活动商品 -// @Description 添加SKU活动商品 -// @Param token header string true "认证token" -// @Param vendorIDs formData string true "厂商ID列表" -// @Param createdFrom formData string true "创建开始日期" -// @Param isAsync formData bool false "是否异步" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshPageActs [put] -func (c *ActController) RefreshPageActs() { - c.callRefreshPageActs(func(params *tActRefreshPageActsParams) (retVal interface{}, errCode string, err error) { - timeList, err := jxutils.BatchStr2Time(params.CreatedFrom) - if err == nil { - var vendorIDs []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs); err == nil { - retVal, err = act.RefreshPageActs(params.Ctx, vendorIDs, timeList[0], params.IsAsync) - } - } - return retVal, "", err - }) -} - -// @Title 将SKU从所有活动中删除 -// @Description 将SKU从所有活动中删除 -// @Param token header string true "认证token" -// @Param skuIDs query string true "skuID列表" -// @Param vendorID query int true "厂商ID" -// @Param types query string false "活动类型列表" -// @Param isAsync query bool false "是否异步" -// @Param isContinueWhenError query bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteSkusFromAct [delete] -func (c *ActController) DeleteSkusFromAct() { - c.callDeleteSkusFromAct(func(params *tActDeleteSkusFromActParams) (retVal interface{}, errCode string, err error) { - var skuIDs, types []int - if err = jxutils.Strings2Objs(params.SkuIDs, &skuIDs, params.Types, &types); err == nil { - retVal, err = act.DeleteSkusFromAct(params.Ctx, params.VendorID, types, skuIDs, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 将门店从所有活动中删除 -// @Description 将门店从所有活动中删除 -// @Param token header string true "认证token" -// @Param storeIDs query string true "门店ID列表" -// @Param vendorID query int true "厂商ID" -// @Param types query string false "活动类型列表" -// @Param isAsync query bool false "是否异步" -// @Param isContinueWhenError query bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteStoresFromAct [delete] -func (c *ActController) DeleteStoresFromAct() { - c.callDeleteStoresFromAct(func(params *tActDeleteStoresFromActParams) (retVal interface{}, errCode string, err error) { - var storeIDs, types []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.Types, &types); err == nil { - retVal, err = act.DeleteStoresFromAct(params.Ctx, params.VendorID, types, storeIDs, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 强制更新商品平台价 -// @Description 强制更新商品平台价 -// @Param token header string true "认证token" -// @Param type formData int true "活动类型,3:直降,4:秒杀(美团当前不支持秒杀)" -// @Param vendorID formData int true "厂商ID,当前只支持,京东:0,京西(用于记录活动信息):9" -// @Param actStoreSkuList formData string true "活动门店商品信息" -// @Param lockTime formData string false "平台价格锁定截止时间" -// @Param isAsync formData bool false "是否异步,缺省否(暂时只支持同步)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ForceUpdateVendorPrice [post] -func (c *ActController) ForceUpdateVendorPrice() { - c.callForceUpdateVendorPrice(func(params *tActForceUpdateVendorPriceParams) (retVal interface{}, errCode string, err error) { - var actStoreSkuList []*act.ActStoreSkuParam - if err = jxutils.Strings2Objs(params.ActStoreSkuList, &actStoreSkuList); err == nil { - timeList, err2 := jxutils.BatchStr2Time(params.LockTime) - if err = err2; err == nil { - retVal, err = act.ForceUpdateVendorPrice(params.Ctx, params.VendorID, params.Type, actStoreSkuList, timeList[0], params.IsAsync) - } - } - return retVal, "", err - }) -} - -// @Title 通过Excel创建活动 -// @Description 通过Excel创建活动 -// @Param token header string true "认证token" -// @Param vendorID formData int true "厂商ID,当前只支持,京东:0,京西(用于记录活动信息):99" -// @Param vendorOrgCode formData string false "厂商内组织代码" -// @Param mixType formData int true "数据处理方式:1(一行一条数据)2(门店与商品相乘)" -// @Param isFocus formData bool true "是否批量关注可售所有商品,默认是" -// @Param isSync formData bool true "是否同步所有未同步的商品,默认是" -// @Param isAsync formData bool false "是否异步" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateActByExcel [post] -func (c *ActController) CreateActByExcel() { - c.callCreateActByExcel(func(params *tActCreateActByExcelParams) (retVal interface{}, errCode string, err error) { - // r := c.Ctx.Request - // files := r.MultipartForm.File["userfiles"] - retVal, err = act.CreateActByExcel(params.Ctx, "files", params.VendorID, params.VendorOrgCode, params.MixType, params.IsFocus, params.IsSync, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} diff --git a/controllers/cms.go b/controllers/cms.go deleted file mode 100644 index 5c4294fde..000000000 --- a/controllers/cms.go +++ /dev/null @@ -1,361 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxcallback/orderman" - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/jxutils/configindb" - "git.rosy.net.cn/jx-callback/business/jxutils/datares" - "git.rosy.net.cn/jx-callback/business/msghub" - "git.rosy.net.cn/jx-callback/globals/api" - "git.rosy.net.cn/jx-callback/globals/api/apimanager" - "github.com/astaxie/beego" -) - -type CmsController struct { - beego.Controller -} - -// @Title 得到地点(省,城市,区)信息 -// @Description 得到地点(省,城市,区)信息。 -// @Param token header string false "认证token" -// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)" -// @Param parentCode query int false "上级地点code,这个指的是国家标准CODE(中国为:100000,北京为:110000,北京市为:110100),不是数据库中的ID" -// @Param level query int false "地点级别:省为1,市为2,区为3,注意直辖市也要分省与市级" -// @Param includeDisabled query bool false "是否包括禁用的城市(缺省不包括)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetPlaces [get] -func (c *CmsController) GetPlaces() { - c.callGetPlaces(func(params *tCmsGetPlacesParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetPlaces(params.Ctx, params.Keyword, params.IncludeDisabled, params.MapData) - return retVal, "", err - }) -} - -// @Title 批量修改地点信息 -// @Description 只支持修改enabled, jd_code和mtps_price这三个属性 -// @Param token header string true "认证token" -// @Param payload formData string true "json数据,place对象数组" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdatePlaces [put] -func (c *CmsController) UpdatePlaces() { - c.callUpdatePlaces(func(params *tCmsUpdatePlacesParams) (retVal interface{}, errCode string, err error) { - placeList := make([]map[string]interface{}, 0) - if err = utils.UnmarshalUseNumber([]byte(params.Payload), &placeList); err == nil { - retVal, err = cms.UpdatePlaces(params.Ctx, placeList, params.Ctx.GetUserName()) - } - return retVal, "", err - }) -} - -// @Title 修改地点信息 -// @Description 只支持修改enabled, jd_code和mtps_price这三个属性 -// @Param token header string true "认证token" -// @Param code formData int true "地点编号,注意是code不是ID" -// @Param enabled formData bool true "是否启用" -// @Param name formData string false "地点名" -// @Param mtpsPrice formData int false "美团配送基础价格" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdatePlace [put] -func (c *CmsController) UpdatePlace() { - c.callUpdatePlace(func(params *tCmsUpdatePlaceParams) (retVal interface{}, errCode string, err error) { - payload := map[string]interface{}{ - "code": params.Code, - "enabled": params.Enabled, - } - if params.Name != "" { - payload["name"] = params.Name - } - if params.MtpsPrice > 0 { - payload["mtpsPrice"] = params.MtpsPrice - } - retVal, err = cms.UpdatePlaces(params.Ctx, []map[string]interface{}{payload}, params.Ctx.GetUserName()) - return retVal, "", err - }) -} - -// @Title 得到服务相关的一些基础信息 -// @Description 得到服务相关的一些基础信息,包括版本,及一些元数据信息 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetServiceInfo [get] -func (c *CmsController) GetServiceInfo() { - c.callGetServiceInfo(func(params *tCmsGetServiceInfoParams) (retVal interface{}, errCode string, err error) { - retVal = cms.GetServiceInfo(params.Ctx) - return retVal, "", err - }) -} - -// @Title 得到七牛上传服务临时token -// @Description 得到七牛上传服务临时token,当前设置为5分钟内有效。正常使用场景为每次上传资源前实时获取,而不是保存下来一直使用,如果hashCode有值,且本地有,可能直接返回URL -// @Param token header string true "认证token" -// @Param suffix query string true "前缀" -// @Param hashCode query string false "图片hash" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetQiniuUploadToken [get] -func (c *CmsController) GetQiniuUploadToken() { - c.callGetQiniuUploadToken(func(params *tCmsGetQiniuUploadTokenParams) (retVal interface{}, errCode string, err error) { - retVal, err = datares.GetQiniuUploadToken(params.Ctx, params.Suffix, params.HashCode) - return retVal, "", err - }) -} - -// 此函数可以不用调用,当前只有菜谱图片在调用 -// @Title 注册数据资源 -// @Description 注册数据资源 -// @Param token header string true "认证token" -// @Param hashCode formData string true "md5" -// @Param resourceURL formData string true "资源URL" -// @Param mimeType formData string true "资源MIME类型,当前只支持:image/jpeg,image/png,video/mpeg,video/mp4" -// @Param name formData string faslse "资源名" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RegisterDataResource [post] -func (c *CmsController) RegisterDataResource() { - c.callRegisterDataResource(func(params *tCmsRegisterDataResourceParams) (retVal interface{}, errCode string, err error) { - // retVal, err = datares.RegisterDataResource(params.Ctx, params.Name, params.ResourceURL, params.MimeType, params.HashCode, nil, model.ImgTypeLocal, true) - return retVal, "", err - }) -} - -// @Title 根据坐标得到区码 -// @Description 根据坐标得到区码,坐标都为火星坐标(有些市是没有区的,比如东莞,这种情况下返回的区码是一个假的区域,即市的编码加上9000000) -// @Param token header string true "认证token" -// @Param lng query number true "经度" -// @Param lat query number true "纬度" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetCoordinateDistrictCode [get] -func (c *CmsController) GetCoordinateDistrictCode() { - c.callGetCoordinateDistrictCode(func(params *tCmsGetCoordinateDistrictCodeParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetCoordinateDistrictCode(params.Ctx, params.Lng, params.Lat) - return retVal, "", err - }) -} - -// @Title 根据坐标得到城市 -// @Description 根据坐标得到城市 -// @Param token header string true "认证token" -// @Param lng query number true "经度" -// @Param lat query number true "纬度" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetCoordinateCityInfo [get] -func (c *CmsController) GetCoordinateCityInfo() { - c.callGetCoordinateCityInfo(func(params *tCmsGetCoordinateCityInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetCoordinateCityInfo(params.Ctx, params.Lng, params.Lat) - return retVal, "", err - }) -} - -// @Title 得到配置参数 -// @Description 得到配置参数 -// @Param token header string true "认证token" -// @Param key query string true "参数名" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetConfig [get] -func (c *CmsController) GetConfig() { - c.callGetConfig(func(params *tCmsGetConfigParams) (retVal interface{}, errCode string, err error) { - retVal, err = configindb.GetConfig(params.Key, "") - return retVal, "", err - }) -} - -// @Title 设置配置参数 -// @Description 设置配置参数 -// @Param token header string true "认证token" -// @Param key query string true "参数名" -// @Param value query string true "参数值" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SetConfig [put] -func (c *CmsController) SetConfig() { - c.callSetConfig(func(params *tCmsSetConfigParams) (retVal interface{}, errCode string, err error) { - retVal, err = configindb.SetConfig(params.Ctx, params.Key, params.Value) - return retVal, "", err - }) -} - -// @Title 从条形码得到商品信息 -// @Description 从条形码得到商品信息 -// @Param token header string true "认证token" -// @Param barCode query string true "条形码" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetProductInfoByBarCode [get] -func (c *CmsController) GetProductInfoByBarCode() { - c.callGetProductInfoByBarCode(func(params *tCmsGetProductInfoByBarCodeParams) (retVal interface{}, errCode string, err error) { - retVal, err = api.ShowAPI.GetProductInfoByBarCode(params.BarCode) - return retVal, "", err - }) -} - -// @Title 得到服务器消息通知 -// @Description 得到服务器消息通知 -// @Param token header string true "认证token" -// @Param storeID query int true "京西门店ID" -// @Param lastOrderTime query string false "最后订单时间(缺省为24小时内)" -// @Param lastOrderSeqID query string false "最后订单流水ID(缺省为0)" -// @Param waitingSecond query int false "等待时间" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetNewOrderMsg [get] -func (c *CmsController) GetNewOrderMsg() { - c.callGetNewOrderMsg(func(params *tCmsGetNewOrderMsgParams) (retVal interface{}, errCode string, err error) { - timeList, err := jxutils.BatchStr2Time(params.LastOrderTime) - if err == nil { - lastOrderSeqID := utils.Str2Int64WithDefault(params.LastOrderSeqID, 0) - retVal, err = msghub.GetMsg(params.Ctx, params.StoreID, timeList[0], lastOrderSeqID, nil, params.WaitingSecond) - } - return retVal, "", err - }) -} - -// @Title 发送新订单消息(测试用) -// @Description 发送新订单消息(测试用) -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单厂商ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /FakeNewOrder [post] -func (c *CmsController) FakeNewOrder() { - c.callFakeNewOrder(func(params *tCmsFakeNewOrderParams) (retVal interface{}, errCode string, err error) { - order, err := orderman.FixedOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) - if err == nil { - msghub.OnNewOrder(order) - } - return retVal, "", err - }) -} - -// @Title 发送消息给相关人员 -// @Description 发送消息给相关人员 -// @Param msgType formData string true "消息类型" -// @Param msgContent formData string true "消息内容" -// @Param mobile formData string false "手机号" -// @Param verifyCode formData string false "验证码" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SendMsg2Somebody [post] -func (c *CmsController) SendMsg2Somebody() { - c.callSendMsg2Somebody(func(params *tCmsSendMsg2SomebodyParams) (retVal interface{}, errCode string, err error) { - err = cms.SendMsg2Somebody(params.Ctx, params.Mobile, params.VerifyCode, params.MsgType, params.MsgContent) - return retVal, "", err - }) -} - -// @Title 新增配置 -// @Description 新增配置 -// @Param token header string true "认证token" -// @Param type formData string true "配置类型(当前只支持PricePack)" -// @Param key formData string true "配置名" -// @Param value formData string true "配置值" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /NewConfig [post] -func (c *CmsController) NewConfig() { - c.callNewConfig(func(params *tCmsNewConfigParams) (retVal interface{}, errCode string, err error) { - err = cms.AddConfig(params.Ctx, params.Key, params.Type, params.Value) - return retVal, "", err - }) -} - -// @Title 删除配置 -// @Description 删除配置 -// @Param token header string true "认证token" -// @Param type query string true "配置类型(当前只支持PricePack)" -// @Param key query string true "配置名" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteConfig [delete] -func (c *CmsController) DeleteConfig() { - c.callDeleteConfig(func(params *tCmsDeleteConfigParams) (retVal interface{}, errCode string, err error) { - err = cms.DeleteConfig(params.Ctx, params.Key, params.Type) - return retVal, "", err - }) -} - -// @Title 修改配置 -// @Description 修改配置 -// @Param token header string true "认证token" -// @Param type formData string true "配置类型(当前只支持PricePack)" -// @Param key formData string true "配置名" -// @Param value formData string true "配置值" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateConfig [put] -func (c *CmsController) UpdateConfig() { - c.callUpdateConfig(func(params *tCmsUpdateConfigParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.UpdateConfig(params.Ctx, params.Key, params.Type, params.Value) - return retVal, "", err - }) -} - -// @Title 查询配置 -// @Description 查询配置 -// @Param token header string fasle "认证token" -// @Param type query string false "配置类型(当前只支持PricePack)" -// @Param key query string false "配置名" -// @Param keyword query string false "关键字" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /QueryConfigs [get] -func (c *CmsController) QueryConfigs() { - c.callQueryConfigs(func(params *tCmsQueryConfigsParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.QueryConfigs(params.Key, params.Type, params.Keyword) - return retVal, "", err - }) -} - -// @Title 生成二维码或条形码 -// @Description 生成二维码或条形码 -// @Param token header string true "认证token" -// @Param width formData int true "图片宽" -// @Param height formData int true "图片高" -// @Param codetype formData string true "编码类型(二维码:qr; 条形码:bar)" -// @Param srcData formData string true "二维码/条形码数据源" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateQrOrBarCode [post] -func (c *CmsController) CreateQrOrBarCode() { - c.callCreateQrOrBarCode(func(params *tCmsCreateQrOrBarCodeParams) (retVal interface{}, errCode string, err error) { - retVal, err = jxutils.CreateQrOrBarCode(params.Width, params.Height, params.Codetype, params.SrcData) - return retVal, "", err - }) -} - -// @Title 查询当前系统中已有的城市中的银行支行 -// @Description 查询当前系统中已有的城市中的银行支行 -// @Param token header string true "认证token" -// @Param cityCode query int false "城市代码" -// @Param bankCode query string false "银行代码" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetCityBankBranches [get] -func (c *CmsController) GetCityBankBranches() { - c.callGetCityBankBranches(func(params *tCmsGetCityBankBranchesParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetCityBankBranches(params.Ctx, params.CityCode, params.BankCode) - return retVal, "", err - }) -} - -// @Title 得到平台的账号信息 -// @Description 得到平台的账号信息 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetVendorOrgCodeInfo [get] -func (c *CmsController) GetVendorOrgCodeInfo() { - c.callGetVendorOrgCodeInfo(func(params *tCmsGetVendorOrgCodeInfoParams) (retVal interface{}, errCode string, err error) { - retVal = apimanager.GetVendorOrgCodeMap(params.Ctx) - return retVal, "", err - }) -} diff --git a/controllers/cms_food_recipe.go b/controllers/cms_food_recipe.go deleted file mode 100644 index 95be21b8a..000000000 --- a/controllers/cms_food_recipe.go +++ /dev/null @@ -1,154 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/userstore" - "github.com/astaxie/beego" -) - -type FoodRecipeController struct { - beego.Controller -} - -// @Title 创建菜谱 -// @Description 创建菜谱 -// @Param token header string true "认证token" -// @Param name formData string true "菜谱名" -// @Param description formData string true "菜谱描述" -// @Param img formData string true "图片"" -// @Param timeInMinute formData int true "大约需要时间(分钟)" -// @Param recipeItems formData string true "菜谱配料" -// @Param recipeSteps formData string true "菜谱步骤" -// @Param authorID formData string false "三方用户ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateFoodRecipe [post] -func (c *FoodRecipeController) CreateFoodRecipe() { - c.callCreateFoodRecipe(func(params *tFoodrecipeCreateFoodRecipeParams) (retVal interface{}, errCode string, err error) { - var ( - foodRecipe *model.FoodRecipe - itemList []*userstore.FoodRecipeItemParam - stepList []*userstore.FoodRecipeStepParam - ) - if err = jxutils.Strings2Objs(params.RecipeItems, &itemList, params.RecipeSteps, &stepList); err == nil { - foodRecipe = &model.FoodRecipe{ - Name: params.Name, - Description: params.Description, - Img: params.Img, - TimeInMinute: params.TimeInMinute, - } - err = userstore.CreateFoodRecipe(params.Ctx, foodRecipe, itemList, stepList, params.AuthorID) - } - return retVal, "", err - }) -} - -// @Title 编辑菜谱 -// @Description 编辑菜谱 -// @Param token header string true "认证token" -// @Param recipeID formData int true "菜谱ID" -// @Param name formData string false "菜谱名" -// @Param description formData string false "菜谱描述" -// @Param img formData string false "图片"" -// @Param timeInMinute formData int false "大约需要时间(分钟)" -// @Param recipeItems formData string false "菜谱配料" -// @Param recipeSteps formData string false "菜谱步骤" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateFoodRecipe [put] -func (c *FoodRecipeController) UpdateFoodRecipe() { - c.callUpdateFoodRecipe(func(params *tFoodrecipeUpdateFoodRecipeParams) (retVal interface{}, errCode string, err error) { - var ( - itemList []*userstore.FoodRecipeItemParam - stepList []*userstore.FoodRecipeStepParam - ) - if err = jxutils.Strings2Objs(params.RecipeItems, &itemList, params.RecipeSteps, &stepList); err == nil { - err = userstore.UpdateFoodRecipe(params.Ctx, params.RecipeID, params.MapData, itemList, stepList) - } - return retVal, "", err - }) -} - -// @Title 查询菜谱列表 -// @Description 查询菜谱列表 -// @Param token header string false "认证token" -// @Param keyword query string false "关键字" -// @Param authorID query string false "创建者ID" -// @Param skuIDs query string false "skuID列表" -// @Param offset query int false "菜谱列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "菜谱列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /QueryFoodRecipes [get] -func (c *FoodRecipeController) QueryFoodRecipes() { - c.callQueryFoodRecipes(func(params *tFoodrecipeQueryFoodRecipesParams) (retVal interface{}, errCode string, err error) { - var skuIDs []int - if err = jxutils.Strings2Objs(params.SkuIDs, &skuIDs); err == nil { - retVal, err = userstore.QueryFoodRecipes(params.Ctx, params.Keyword, params.AuthorID, skuIDs, params.Offset, params.PageSize) - } - return retVal, "", err - }) -} - -// @Title 得到我的推荐菜谱列表 -// @Description 得到我的推荐菜谱列表 -// @Param token header string false "认证token" -// @Param keyword query string false "关键字" -// @Param offset query int false "菜谱列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "菜谱列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetRecommendFoodRecipes [get] -func (c *FoodRecipeController) GetRecommendFoodRecipes() { - c.callGetRecommendFoodRecipes(func(params *tFoodrecipeGetRecommendFoodRecipesParams) (retVal interface{}, errCode string, err error) { - retVal, err = userstore.GetRecommendFoodRecipes(params.Ctx, params.Keyword, params.Offset, params.PageSize) - return retVal, "", err - }) -} - -// @Title 得到菜谱详情 -// @Description 得到菜谱详情 -// @Param token header string false "认证token" -// @Param recipeID query int true "菜谱ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetRecipeDetail [get] -func (c *FoodRecipeController) GetRecipeDetail() { - c.callGetRecipeDetail(func(params *tFoodrecipeGetRecipeDetailParams) (retVal interface{}, errCode string, err error) { - retVal, err = userstore.GetRecipeDetail(params.Ctx, params.RecipeID) - return retVal, "", err - }) -} - -// @Title 对菜谱投票 -// @Description 对菜谱投票 -// @Param token header string true "认证token" -// @Param recipeID formData int true "菜谱ID" -// @Param voteType formData int true "-1:踩,0:取消之前的投票,1:赞" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /VoteFoodRecipe [post] -func (c *FoodRecipeController) VoteFoodRecipe() { - c.callVoteFoodRecipe(func(params *tFoodrecipeVoteFoodRecipeParams) (retVal interface{}, errCode string, err error) { - err = userstore.VoteFoodRecipe(params.Ctx, params.RecipeID, params.VoteType) - return retVal, "", err - }) -} - -// @Title 删除菜谱 -// @Description 删除菜谱 -// @Param token header string true "认证token" -// @Param recipeIDs query string true "菜谱ID列表" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteRecipes [delete] -func (c *FoodRecipeController) DeleteRecipes() { - c.callDeleteRecipes(func(params *tFoodrecipeDeleteRecipesParams) (retVal interface{}, errCode string, err error) { - var recipeIDs []int - if err = jxutils.Strings2Objs(params.RecipeIDs, &recipeIDs); err == nil { - retVal, err = userstore.DeleteRecipes(params.Ctx, recipeIDs) - } - return retVal, "", err - }) -} diff --git a/controllers/cms_msg.go b/controllers/cms_msg.go deleted file mode 100644 index b408c8876..000000000 --- a/controllers/cms_msg.go +++ /dev/null @@ -1,154 +0,0 @@ -package controllers - -import ( - "net/http" - "time" - - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg" - "git.rosy.net.cn/jx-callback/business/model" - "github.com/astaxie/beego" -) - -type MsgController struct { - beego.Controller -} - -// @Title 发送微信消息 -// @Description 发送微信消息 -// @Param token header string true "认证token" -// @Param storeIDs formData string true "门店 ID列表" -// @Param title formData string true "消息标题" -// @Param content formData string true "消息内容" -// @Param isAsync formData bool false "是否异步操作,缺省否" -// @Param isContinueWhenError formData bool false "单个失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SendStoreMessage [post] -func (c *MsgController) SendStoreMessage() { - c.callSendStoreMessage(func(params *tMsgSendStoreMessageParams) (retVal interface{}, errCode string, err error) { - var storeIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err != nil { - return retVal, "", err - } - retVal, err = weixinmsg.SendStoreMessage(params.Ctx, params.Title, params.Content, storeIDs, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 发送用户微信消息 -// @Description 发送用户微信消息 -// @Param token header string true "认证token" -// @Param userIDs formData string true "用户 ID列表" -// @Param title formData string true "消息标题" -// @Param content formData string true "消息内容" -// @Param isAsync formData bool false "是否异步操作,缺省否" -// @Param isContinueWhenError formData bool false "单个失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SendUserMessage [post] -func (c *MsgController) SendUserMessage() { - c.callSendUserMessage(func(params *tMsgSendUserMessageParams) (retVal interface{}, errCode string, err error) { - var userIDs []string - if err = jxutils.Strings2Objs(params.UserIDs, &userIDs); err != nil { - return retVal, "", err - } - retVal, err = weixinmsg.SendUserMessage(params.Ctx, params.Title, params.Content, userIDs, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 门店读微信消息 -// @Description 门店读微信消息(此API是自动调用的) -// @Param token header string true "认证token" -// @Param msgID formData int true "消息ID" -// @Param msgStatusID formData int true "消息状态ID" -// @Param redirectURL formData string false "重定向URL" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ReadStoreMessage [put] -func (c *MsgController) ReadStoreMessage() { - redirectURL := "" - c.callReadStoreMessage(func(params *tMsgReadStoreMessageParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.ReadStoreMessage(params.Ctx, params.MsgID, params.MsgStatusID) - retRedirectURL := retVal.(string) - if retRedirectURL != "" { - redirectURL = retRedirectURL - } else { - redirectURL = params.RedirectURL - } - if redirectURL != "" { - errCode = model.ErrorCodeIgnore - } - return retVal, errCode, err - }) - if redirectURL != "" { - c.Redirect(redirectURL, http.StatusTemporaryRedirect) - } -} - -// @Title 得到发送的微信消息列表 -// @Description 得到发送的微信消息列表 -// @Param token header string true "认证token" -// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)" -// @Param msgIDs query string false "msg IDs列表" -// @Param storeIDs query string false "门店 ID列表" -// @Param types query string false "类型列表,当前只有一个类型,写死[1]" -// @Param fromTime query string false "创建起始时间" -// @Param toTime query string false "创建结束时间" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreMessages [get] -func (c *MsgController) GetStoreMessages() { - c.callGetStoreMessages(func(params *tMsgGetStoreMessagesParams) (retVal interface{}, errCode string, err error) { - var msgIDs, storeIDs, types []int - var timeList []time.Time - if err = jxutils.Strings2Objs(params.MsgIDs, &msgIDs, params.StoreIDs, &storeIDs, params.Types, &types); err != nil { - return retVal, "", err - } - if timeList, err = jxutils.BatchStr2Time(params.FromTime, params.ToTime); err != nil { - return retVal, "", err - } - retVal, err = cms.GetStoreMessages(params.Ctx, msgIDs, storeIDs, types, timeList[0], timeList[1], params.Keyword, params.Offset, params.PageSize) - return retVal, "", err - }) -} - -// @Title 得到发送的微信消息状态列表 -// @Description 得到发送的微信消息状态列表 -// @Param token header string true "认证token" -// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)" -// @Param msgIDs query string false "msg IDs列表" -// @Param storeIDs query string false "门店 ID列表" -// @Param fromTime query string false "创建起始时间" -// @Param toTime query string false "创建结束时间" -// @Param fromReadCount query int false "已读次数开始" -// @Param toReadCount query int false "已读次数结束" -// @Param offset query int false "消息状态列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "消息状态列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreMessageStatuses [get] -func (c *MsgController) GetStoreMessageStatuses() { - c.callGetStoreMessageStatuses(func(params *tMsgGetStoreMessageStatusesParams) (retVal interface{}, errCode string, err error) { - var msgIDs, storeIDs []int - var timeList []time.Time - if err = jxutils.Strings2Objs(params.MsgIDs, &msgIDs, params.StoreIDs, &storeIDs); err != nil { - return retVal, "", err - } - if timeList, err = jxutils.BatchStr2Time(params.FromTime, params.ToTime); err != nil { - return retVal, "", err - } - if _, ok := params.MapData["fromReadCount"]; !ok { - params.FromReadCount = -1 - } - if _, ok := params.MapData["toReadCount"]; !ok { - params.ToReadCount = -1 - } - retVal, err = cms.GetStoreMessageStatuses(params.Ctx, msgIDs, storeIDs, params.FromReadCount, params.ToReadCount, timeList[0], timeList[1], params.Keyword, params.Offset, params.PageSize) - return retVal, "", err - }) -} diff --git a/controllers/cms_sku.go b/controllers/cms_sku.go deleted file mode 100644 index 79b183b6b..000000000 --- a/controllers/cms_sku.go +++ /dev/null @@ -1,558 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxstore/misc" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/model/dao" - "git.rosy.net.cn/jx-callback/globals" - "github.com/astaxie/beego" -) - -type SkuController struct { - beego.Controller -} - -// @Title 得到厂商商品类别 -// @Description 得到厂商商品类别(区别于商家SKU类别) -// @Param token header string true "认证token" -// @Param vendorID query int true "厂商ID" -// @Param parentID query string false "父ID,-1表示所有,缺省为空" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetVendorCategories [get] -func (c *SkuController) GetVendorCategories() { - c.callGetVendorCategories(func(params *tSkuGetVendorCategoriesParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetVendorCategories(params.Ctx, params.VendorID, params.ParentID) - return retVal, "", err - }) -} - -// @Title 得到商品类别 -// @Description 得到商品类别(区别于厂商家SKU类别) -// @Param token header string false "认证token" -// @Param parentID query int false "父ID,-1表示所有,缺省为-1" -// @Param isExd query bool false "是否要查饿鲜达分类" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetCategories [get] -func (c *SkuController) GetCategories() { - c.callGetCategories(func(params *tSkuGetCategoriesParams) (retVal interface{}, errCode string, err error) { - if c.GetString("parentID") == "" { - params.ParentID = -1 - } - retVal, err = cms.GetCategories(params.Ctx, params.ParentID, params.IsExd) - return retVal, "", err - }) -} - -// @Title 新增商品类别 -// @Description 新增商品类别(区别于厂商家SKU类别) -// @Param token header string true "认证token" -// @Param payload formData string true "json数据,skuCategory对象()" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddCategory [post] -func (c *SkuController) AddCategory() { - c.callAddCategory(func(params *tSkuAddCategoryParams) (retVal interface{}, errCode string, err error) { - cat := &model.SkuCategory{} - if err = utils.UnmarshalUseNumber([]byte(params.Payload), cat); err == nil { - retVal, err = cms.AddCategory(params.Ctx, cat, params.Ctx.GetUserName()) - } - return retVal, "", err - }) -} - -// @Title 修改商品类别 -// @Description 修改商品类别(区别于厂商家SKU类别) -// @Param token header string true "认证token" -// @Param categoryID formData int true "类别ID,payload中的相应字段会被忽略" -// @Param payload formData string true "json数据,skuCategory对象()" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateCategory [put] -func (c *SkuController) UpdateCategory() { - c.callUpdateCategory(func(params *tSkuUpdateCategoryParams) (retVal interface{}, errCode string, err error) { - payload := make(map[string]interface{}) - if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil { - retVal, err = cms.UpdateCategory(params.Ctx, params.CategoryID, payload, params.Ctx.GetUserName()) - } - return retVal, "", err - }) -} - -// @Title 商品类别重排序 -// @Description 商品类别重排序(区别于厂商家SKU类别) -// @Param token header string true "认证token" -// @Param categoryID formData int true "父ID" -// @Param categoryIDs formData string true "同一父类别下的所有子类别ID列表([1,2,3,4])" -// @Param isExd query bool false "是否要查饿鲜达分类" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ReorderCategories [put] -func (c *SkuController) ReorderCategories() { - c.callReorderCategories(func(params *tSkuReorderCategoriesParams) (retVal interface{}, errCode string, err error) { - var idList []int - if err = utils.UnmarshalUseNumber([]byte(params.CategoryIDs), &idList); err == nil { - err = cms.ReorderCategories(params.Ctx, params.CategoryID, idList, params.Ctx.GetUserName(), params.IsExd) - } - return retVal, "", err - }) -} - -// @Title 删除商品类别 -// @Description 删除商品类别,只有无商品且无子类别的才能删除 -// @Param token header string true "认证token" -// @Param categoryID query int true "商品类别ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteCategory [delete] -func (c *SkuController) DeleteCategory() { - c.callDeleteCategory(func(params *tSkuDeleteCategoryParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.DeleteCategory(params.Ctx, params.CategoryID, params.Ctx.GetUserName()) - return retVal, "", err - }) -} - -// @Title 同步商家SKU类别 -// @Description 同步商家SKU类别 -// @Param token header string true "认证token" -// @Param categoryID query int true "SKU类别ID, -1表示所有" -// @Param isAsync query bool false "是否异步" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncCategory [put] -func (c *SkuController) SyncCategory() { - c.callSyncCategory(func(params *tSkuSyncCategoryParams) (retVal interface{}, errCode string, err error) { - db := dao.GetDB() - retVal, err = cms.CurVendorSync.SyncCategory(params.Ctx, db, params.CategoryID, params.IsAsync, params.Ctx.GetUserName()) - return retVal, "", err - }) -} - -// @Title 得到商品信息 -// @Description 得到商品信息,如下条件之间是与的关系 -// @Param token header string true "认证token" -// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)" -// @Param nameIDs query string false "SkuName IDs列表" -// @Param skuIDs query string false "Sku ID列表" -// @Param vendorSkuIDs query string false "厂商SKU ID列表" -// @Param name query string false "商品名称(不要求完全一致)" -// @Param prefix query string false "商品前缀(不要求完全一致)" -// @Param placeCond query string false "查询地点的条件(如果此字段没有设置,placeCode与isGlobal无效),and:与,or:或,指的是placeCode,isGlobal这两个条件间的关系,这组条件与其它条件都是与的关系" -// @Param placeCode query int false "可售地点Code" -// @Param isGlobal query bool false "是否全球可售" -// @Param categoryID query int false "商品名所属类别ID" -// @Param skuCategoryID query int false "商品所属类别ID" -// @Param unit query string false "商品单位" -// @Param isSpu query bool false "是否是SPU" -// @Param isExd query bool false "是否是饿鲜达商品" -// @Param fromStatus query int false "查询起始状态(0:下架,1:正常)" -// @Param toStatus query int false "查询起始状态(0:下架,1:正常)" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" -// @Param isBySku query bool false "是否将sku拆开,缺省为false" -// @Param isQueryMidPrice query bool false "是否查询中位价缺省为false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetSkuNames [get,post] -func (c *SkuController) GetSkuNames() { - c.callGetSkuNames(func(params *tSkuGetSkuNamesParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetSkuNames(params.Ctx, params.Keyword, params.IsBySku, params.IsQueryMidPrice, params.MapData, params.Offset, params.PageSize) - return retVal, "", err - }) -} - -// @Title 新增商品名(及商品)信息 -// @Description 新增商品名(及商品)信息 -// @Param token header string true "认证token" -// @Param payload formData string true "json数据,SkuNameExt对象(),可传Skus及Places" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddSkuName [post] -func (c *SkuController) AddSkuName() { - c.callAddSkuName(func(params *tSkuAddSkuNameParams) (retVal interface{}, errCode string, err error) { - skuName := &model.SkuNameExt{} - if err = utils.UnmarshalUseNumber([]byte(params.Payload), skuName); err == nil { - retVal, err = cms.AddSkuName(params.Ctx, skuName, params.Ctx.GetUserName()) - } - return retVal, "", err - }) -} - -// @Title 修改商品名信息 -// @Description 修改商品名信息,注意:如果Places没有变动,不要传此字段,否则会导致不必要的删除与新增 -// @Param token header string true "认证token" -// @Param nameID formData int true "需要修改的商品名ID,payload中的相应数据会被忽略" -// @Param payload formData string true "json数据,SkuNameExt对象(),Skus无效, Places有效" -// @Param isExd formData bool fasle "是否要修改饿鲜达商品" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateSkuName [put] -func (c *SkuController) UpdateSkuName() { - c.callUpdateSkuName(func(params *tSkuUpdateSkuNameParams) (retVal interface{}, errCode string, err error) { - // var payload map[string]interface{} - // dummySkuName := &model.SkuName{} - payload := make(map[string]interface{}) - if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil { - delete(payload, "exPrefix") - delete(payload, "exPrefixBegin") - delete(payload, "exPrefixEnd") - delete(payload, "imgWaterMark") - delete(payload, "exVendorID") - retVal, err = cms.UpdateSkuName(params.Ctx, params.NameID, payload, params.IsExd) - } - return retVal, "", err - }) -} - -// @Title 删除商品名 -// @Description 此前商品名下的所有商品也会被级连删除 -// @Param token header string true "认证token" -// @Param nameID query int true "商品名ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteSkuName [delete] -func (c *SkuController) DeleteSkuName() { - c.callDeleteSkuName(func(params *tSkuDeleteSkuNameParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.DeleteSkuName(params.Ctx, params.NameID, params.Ctx.GetUserName()) - return retVal, "", err - }) -} - -// @Title 新增商品 -// @Description 新增商品 -// @Param token header string true "认证token" -// @Param nameID formData int true "商品名ID, playload中的相应字段会被忽略" -// @Param payload formData string true "json数据,Sku对象()" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddSku [post] -func (c *SkuController) AddSku() { - c.callAddSku(func(params *tSkuAddSkuParams) (retVal interface{}, errCode string, err error) { - sku := &model.Sku{} - if err = utils.UnmarshalUseNumber([]byte(params.Payload), sku); err == nil { - retVal, err = cms.AddSku(params.Ctx, params.NameID, sku, params.Ctx.GetUserName()) - } - return retVal, "", err - }) -} - -// @Title 修改商品信息 -// @Description 修改商品信息 -// @Param token header string true "认证token" -// @Param skuID formData int true "需要修改的商品名ID,payload中的相应数据会被忽略" -// @Param payload formData string true "json数据,Sku对象" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateSku [put] -func (c *SkuController) UpdateSku() { - c.callUpdateSku(func(params *tSkuUpdateSkuParams) (retVal interface{}, errCode string, err error) { - payload := make(map[string]interface{}) - if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil { - retVal, err = cms.UpdateSku(params.Ctx, params.SkuID, payload) - } - return retVal, "", err - }) -} - -// @Title 删除商品 -// @Description 删除商品 -// @Param token header string true "认证token" -// @Param skuID query int true "商品ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteSku [delete] -func (c *SkuController) DeleteSku() { - c.callDeleteSku(func(params *tSkuDeleteSkuParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.DeleteSku(params.Ctx, params.SkuID, params.Ctx.GetUserName()) - return retVal, "", err - }) -} - -// @Title 新增商品名可售地点绑定(不推荐使用) -// @Description 新增商品名可售地点绑定(不推荐使用) -// @Param token header string true "认证token" -// @Param nameID formData int true "商品名ID" -// @Param placeCode formData int true "地点代码" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddSkuNamePlace [post] -func (c *SkuController) AddSkuNamePlace() { - c.callAddSkuNamePlace(func(params *tSkuAddSkuNamePlaceParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.AddSkuNamePlace(params.Ctx, params.NameID, params.PlaceCode, params.Ctx.GetUserName()) - return retVal, "", err - }) -} - -// @Title 删除商品名可售地点绑定(不推荐使用) -// @Description 删除商品名可售地点绑定(不推荐使用) -// @Param token header string true "认证token" -// @Param nameID query int true "商品名ID" -// @Param placeCode query int true "地点代码" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteSkuNamePlace [delete] -func (c *SkuController) DeleteSkuNamePlace() { - c.callDeleteSkuNamePlace(func(params *tSkuDeleteSkuNamePlaceParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.DeleteSkuNamePlace(params.Ctx, params.NameID, params.PlaceCode, params.Ctx.GetUserName()) - return retVal, "", err - }) -} - -// // @Title 远程查询厂商SKU信息 -// // @Description 远程查询厂商SKU信息,这个是实时调用API远程查询(不推荐使用) -// // @Param token header string true "认证token" -// // @Param vendorSkuID query string true "sku ID" -// // @Param vendorID query int true "门店所属的厂商ID" -// // @Param vendorOrgCode query string false "厂商内组织代码" -// // @Success 200 {object} controllers.CallResult -// // @Failure 200 {object} controllers.CallResult -// // @router /GetVendorSku [get] -// func (c *SkuController) GetVendorSku() { -// c.callGetVendorSku(func(params *tSkuGetVendorSkuParams) (retVal interface{}, errCode string, err error) { -// retVal, err = cms.GetVendorSku(params.Ctx, params.VendorID, params.VendorOrgCode, params.VendorSkuID) -// return retVal, "", err -// }) -// } - -// @Title 同步商家SKU -// @Description 同步商家SKU -// @Param token header string true "认证token" -// @Param nameID formData int true "name ID, -1表示所有" -// @Param skuID formData int true "sku ID, -1表示所有" -// @Param isAsync formData bool false "是否异步" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncSku [put] -func (c *SkuController) SyncSku() { - c.callSyncSku(func(params *tSkuSyncSkuParams) (retVal interface{}, errCode string, err error) { - db := dao.GetDB() - retVal, err = cms.CurVendorSync.SyncSku(params.Ctx, db, params.NameID, params.SkuID, params.IsAsync, params.IsContinueWhenError, params.Ctx.GetUserName()) - return retVal, "", err - }) -} - -// @Title 获取敏感词列表 -// @Description 获取敏感词列表 -// @Param token header string true "认证token" -// @Param vendorID query int false "VendorID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetSensitiveWordList [get] -func (c *SkuController) GetSensitiveWordList() { - c.callGetSensitiveWordList(func(params *tSkuGetSensitiveWordListParams) (retVal interface{}, errCode string, err error) { - sensitiveWordList, err := dao.GetSensitiveWordList(params.VendorID) - var wordList []string - for _, value := range sensitiveWordList { - wordList = append(wordList, value.Word) - } - retVal = wordList - return retVal, "", err - }) -} - -// @Title 插入敏感词列表 -// @Description 插入敏感词列表 -// @Param token header string true "认证token" -// @Param word formData string true "关键词名字" -// @Param vendorID formData int false "VendorID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /InsertSensitiveWord [post] -func (c *SkuController) InsertSensitiveWord() { - c.callInsertSensitiveWord(func(params *tSkuInsertSensitiveWordParams) (retVal interface{}, errCode string, err error) { - err = dao.InsertSensitiveWord(params.Word, params.VendorID, params.Ctx.GetUserName()) - return retVal, "", err - }) -} - -// @Title 修改敏感词列表 -// @Description 修改敏感词列表 -// @Param token header string true "认证token" -// @Param word formData string true "关键词名字" -// @Param vendorID formData int false "VendorID" -// @Param ID formData int false "关键词ID" -// @Param Status formData int false "状态,0为修改默认,1为删除" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateSensitiveWord [put] -func (c *SkuController) UpdateSensitiveWord() { - c.callUpdateSensitiveWord(func(params *tSkuUpdateSensitiveWordParams) (retVal interface{}, errCode string, err error) { - //word := &model.SensitiveWord{ - // VendorID: params.VendorID, - // Word: params.Word, - //} - globals.SugarLogger.Debug("UpdateSensitiveWord入参params:", params) - words, err := dao.GetSensitiveWordList(params.VendorID) - word := words[0] - word.Word = params.Word - if params.ID != 0 { - word.ModelIDCULD.ID = params.ID - } - if params.Status == 1 { - retVal, err = dao.DeleteSensitiveWord(word, params.ID, params.Ctx.GetUserName(), params.VendorID) - } else { - retVal, err = dao.UpdateSensitiveWord(word, params.VendorID, params.ID, params.Ctx.GetUserName()) - } - return retVal, "", err - }) -} - -// @Title 子分类下商品的重排序 -// @Description 子分类下商品的重排序 -// @Param token header string true "认证token" -// @Param catID formData int true "商品子分类" -// @Param skuIDs formData string true "商品子分类下商品列表" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SortCategorySkus [post] -func (c *SkuController) SortCategorySkus() { - c.callSortCategorySkus(func(params *tSkuSortCategorySkusParams) (retVal interface{}, errCode string, err error) { - var skuIDList []int - if err = jxutils.Strings2Objs(params.SkuIDs, &skuIDList); err == nil { - err = cms.SortCategorySkus(params.Ctx, params.CatID, skuIDList) - } - - return retVal, "", err - }) -} - -// @Title 按照当前城市近30天销量排序,显示本店价格,附近5公里平均价格,差评数量,本店销量情况,本市总销量, -// @Description 按照当前城市近30天销量排序,显示本店价格,附近5公里平均价格,差评数量,本店销量情况,本市总销量, -// @Param token header string true "认证token" -// @Param storeID query int true "京西门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreSkuSalesInfo [get] -func (c *SkuController) GetStoreSkuSalesInfo() { - c.callGetStoreSkuSalesInfo(func(params *tSkuGetStoreSkuSalesInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = misc.GetStoreSkuSalesInfo(params.Ctx, params.StoreID) - return retVal, "", err - }) -} - -// @Title 根据名字查询京东商品UPC信息 -// @Description 根据名字查询京东商品UPC信息 -// @Param token header string true "认证token" -// @Param name query string false "商品名" -// @Param upcCode query string false "upcCode,不支持模糊" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetJdUpcCodeByName [get] -func (c *SkuController) GetJdUpcCodeByName() { - c.callGetJdUpcCodeByName(func(params *tSkuGetJdUpcCodeByNameParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetJdUpcCodeByName(params.Ctx, params.Name, params.UpcCode) - return retVal, "", err - }) -} - -// @Title 批量设置商品额外前缀 -// @Description 批量设置商品额外前缀 -// @Param token header string true "认证token" -// @Param nameIDs formData string true "商品nameIDs" -// @Param exPrefix formData string false "商品额外前缀" -// @Param fromDate formData string true "生效开始时间,格式 2006-01-01 " -// @Param toDate formData string true "生效结束时间,格式 2006-01-01 " -// @Param imgWaterMark formData string false "商品水印图" -// @Param vendorID formData int true "平台ID" -// @Param isAsync formData bool false "是否异步" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateSkuNamesExPrefix [put] -func (c *SkuController) UpdateSkuNamesExPrefix() { - c.callUpdateSkuNamesExPrefix(func(params *tSkuUpdateSkuNamesExPrefixParams) (retVal interface{}, errCode string, err error) { - var skuIDList []int - if err = jxutils.Strings2Objs(params.NameIDs, &skuIDList); err == nil { - retVal, err = cms.UpdateSkuNamesExPrefix(params.Ctx, skuIDList, params.ImgWaterMark, params.VendorID, params.ExPrefix, params.FromDate, params.ToDate, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 合并饿鲜达商品库(必须要在饿鲜达系统中先导入商品) -// @Description 合并饿鲜达商品库(必须要在饿鲜达系统中先导入商品) -// @Param token header string true "认证token" -// @Param isAsync formData bool false "是否异步" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SumExianDaDepot [put] -func (c *SkuController) SumExianDaDepot() { - c.callSumExianDaDepot(func(params *tSkuSumExianDaDepotParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.SumExianDaDepot(params.Ctx, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 根据饿百上已经分类的商品刷新京西库中饿鲜达商品分类 -// @Description 根据饿百上已经分类的商品刷新京西库中饿鲜达商品分类 -// @Param token header string true "认证token" -// @Param isAsync formData bool false "是否异步" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateExianDaSkuCategory [put] -func (c *SkuController) UpdateExianDaSkuCategory() { - c.callUpdateExianDaSkuCategory(func(params *tSkuUpdateExianDaSkuCategoryParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.UpdateExianDaSkuCategory(params.Ctx, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 根据Excel创建标品 -// @Description 根据Excel创建标品 -// @Param token header string true "认证token" -// @Param categroyID formData int true "分类ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateUpcSkuByExcel [post] -func (c *SkuController) CreateUpcSkuByExcel() { - c.callCreateUpcSkuByExcel(func(params *tSkuCreateUpcSkuByExcelParams) (retVal interface{}, errCode string, err error) { - r := c.Ctx.Request - files := r.MultipartForm.File["userfiles"] - retVal, err = cms.CreateUpcSkuByExcel(params.Ctx, files, params.CategroyID) - return retVal, "", err - }) -} - -// @Title 恢复被删除的京东商品库 -// @Description -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshJdDepot [post] -func (c *SkuController) RefreshJdDepot() { - c.callRefreshJdDepot(func(params *tSkuRefreshJdDepotParams) (retVal interface{}, errCode string, err error) { - err = cms.RefreshJdDepot(params.Ctx) - return retVal, "", err - }) -} - -// @Title 批量设置商品额外信息 -// @Description 批量设置商品额外信息 -// @Param token header string true "认证token" -// @Param nameIDs formData string true "商品nameIDs" -// @Param exPrefix formData string false "商品额外前缀" -// @Param fromDate formData string true "生效开始时间,格式 2006-01-01 " -// @Param toDate formData string true "生效结束时间,格式 2006-01-01 " -// @Param imgWaterMark formData string false "商品水印图" -// @Param vendorID formData int true "平台ID" -// @Param isAsync formData bool false "是否异步" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateSkuExinfoMap [put] -func (c *SkuController) UpdateSkuExinfoMap() { - c.callUpdateSkuExinfoMap(func(params *tSkuUpdateSkuExinfoMapParams) (retVal interface{}, errCode string, err error) { - var skuIDList []int - if err = jxutils.Strings2Objs(params.NameIDs, &skuIDList); err == nil { - retVal, err = cms.UpdateSkuExinfoMap(params.Ctx, skuIDList, params.ImgWaterMark, params.VendorID, params.ExPrefix, params.FromDate, params.ToDate, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} diff --git a/controllers/cms_store.go b/controllers/cms_store.go deleted file mode 100644 index 5a2a48b5f..000000000 --- a/controllers/cms_store.go +++ /dev/null @@ -1,922 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxstore/common" - "git.rosy.net.cn/jx-callback/business/jxstore/misc" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/jxutils/netprinter" - "git.rosy.net.cn/jx-callback/business/model" - "github.com/astaxie/beego" -) - -type StoreController struct { - beego.Controller -} - -// @Title 得到京西门店信息 -// @Description 得到京西门店信息,如下条件之间是与的关系 -// @Param token header string false "认证token" -// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)" -// @Param storeID query int false "门店ID" -// @Param startStoreID query int false "起始门店ID" -// @Param coordinateType query int false "返回坐标类型,0:火星坐标,1:百度,缺省0" -// @Param storeIDs query string false "门店ID列表" -// @Param name query string false "门店名称(不要求完全一致)" -// @Param placeID query int false "所属地点ID" -// @Param placeLevel query int false "所属地点级别" -// @Param address query string false "门店地址" -// @Param tel query string false "电话" -// @Param statuss query string false "门店状态列表[-1,0,1],(-1:禁用;0:休息,关店;1:正常开店),缺省不限制" -// @Param vendorStoreCond query string false "查询关联门店的条件(如果此字段没有设置,vendorStoreConds无效),and:与,or:或,指的是vendorStoreConds里的条件间的关系,这组条件与其它条件都是与的关系" -// @Param vendorStoreConds query string false "为厂商条件对象{vendorID: cond},注意vendorID是字符串形式,cond,-1:没有关联,0:不限定,1:有关联,缺省为0,其它值表示vendorOrgCode" -// @Param courierStoreCond query string false "查询关联门店的条件(如果此字段没有设置,courierStoreConds无效),and:与,or:或,指的是courierStoreConds里的条件间的关系,这组条件与其它条件都是与的关系" -// @Param courierStoreConds query string false "为厂商条件对象{vendorID: cond},注意vendorID是字符串形式,cond,-1:没有关联,0:不限定,1:有关联,缺省为0" -// @Param mapLongitude query string false "地图中心经度" -// @Param mapLatitude query string false "地图中心纬度" -// @Param mapRadius query int false "地图半径(单位为米)" -// @Param orderTimeFrom query string false "订单创建起始时间" -// @Param orderTimeTo query string false "订单创建结束时间" -// @Param orderCountFrom query int false "订单量起始" -// @Param orderCountTo query int false "订单量结束" -// @Param marketManPhone query string false "市场负责人电话" -// @Param briefLevel query int false "返回信息精简模式" -// @Param storeLevels query string false "门店等级" -// @Param marketManPhones query string false "市场负责人电话们" -// @Param earningType query int false "结算方式(1为报价,2为扣点)" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStores [get,post] -func (c *StoreController) GetStores() { - c.callGetStores(func(params *tStoreGetStoresParams) (retVal interface{}, errCode string, err error) { - timeList, err := jxutils.BatchStr2Time(params.OrderTimeFrom, params.OrderTimeTo) - if err == nil { - retVal, err = cms.GetStores(params.Ctx, params.Keyword, params.MapData, params.Offset, params.PageSize, timeList[0], timeList[1], params.OrderCountFrom, params.OrderCountTo) - } - return retVal, "", err - }) -} - -// @Title 远程查询厂商门店信息 -// @Description 远程查询厂商门店信息,这个是实时调用API远程查询 -// @Param token header string true "认证token" -// @Param vendorStoreID query string true "门店ID" -// @Param vendorID query int true "门店所属的厂商ID" -// @Param vendorOrgCode query string false "厂商内组织代码" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetVendorStore [get] -func (c *StoreController) GetVendorStore() { - c.callGetVendorStore(func(params *tStoreGetVendorStoreParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetVendorStore(params.Ctx, params.VendorID, params.VendorOrgCode, params.VendorStoreID) - return retVal, "", err - }) -} - -// @Title 修改门店信息 -// @Description 修改门店信息 -// @Param token header string true "认证token" -// @Param storeID formData int true "京西门店编号,payload中的京西门店编号会被忽略" -// @Param payload formData string true "json数据,store对象" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateStore [put] -func (c *StoreController) UpdateStore() { - c.callUpdateStore(func(params *tStoreUpdateStoreParams) (retVal interface{}, errCode string, err error) { - payload := make(map[string]interface{}) - if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil { - retVal, err = cms.UpdateStore(params.Ctx, params.StoreID, payload, params.Ctx.GetUserName()) - } - return retVal, "", err - }) -} - -// @Title 删除京西门店 -// @Description 删除京西门店 -// @Param token header string true "认证token" -// @Param storeID query int true "门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteStore [delete] -func (c *StoreController) DeleteStore() { - c.callDeleteStore(func(params *tStoreDeleteStoreParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.DeleteStore(params.Ctx, params.StoreID) - return retVal, "", err - }) -} - -// @Title 启用所有临时休息门店 -// @Description 启用所有临时休息门店 -// @Param token header string true "认证token" -// @Param isAsync formData bool true "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /EnableHaveRestStores [put] -func (c *StoreController) EnableHaveRestStores() { - c.callEnableHaveRestStores(func(params *tStoreEnableHaveRestStoresParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.EnableHaveRestStores(params.Ctx, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 创建京西门店 -// @Description 创建京西门店 -// @Param token header string true "认证token" -// @Param payload formData string true "json数据,store对象" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateStore [post] -func (c *StoreController) CreateStore() { - c.callCreateStore(func(params *tStoreCreateStoreParams) (retVal interface{}, errCode string, err error) { - store := &cms.StoreExt{} - if err = utils.UnmarshalUseNumber([]byte(params.Payload), store); err == nil { - retVal, err = cms.CreateStore(params.Ctx, store, params.Ctx.GetUserName()) - } - return retVal, "", err - }) -} - -// @Title 得到门店映射信息 -// @Description 得到门店映射信息 -// @Param token header string false "认证token" -// @Param storeID query int true "门店ID" -// @Param vendorID query int false "厂商ID(缺省为全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreVendorMaps [get] -func (c *StoreController) GetStoreVendorMaps() { - c.callGetStoreVendorMaps(func(params *tStoreGetStoreVendorMapsParams) (retVal interface{}, errCode string, err error) { - if c.GetString("vendorID") == "" { - params.VendorID = -1 - } - retVal, err = cms.GetStoreVendorMaps(params.Ctx, nil, params.StoreID, params.VendorID) - return retVal, "", err - }) -} - -// @Title 修改门店映射信息 -// @Description 修改门店映射信息 -// @Param token header string true "认证token" -// @Param storeID query int true "门店ID" -// @Param vendorID query int true "厂商ID" -// @Param payload formData string true "json数据,storeMap对象" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateStoreVendorMap [put] -func (c *StoreController) UpdateStoreVendorMap() { - c.callUpdateStoreVendorMap(func(params *tStoreUpdateStoreVendorMapParams) (retVal interface{}, errCode string, err error) { - payload := make(map[string]interface{}) - if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil { - retVal, err = cms.UpdateStoreVendorMap(params.Ctx, nil, params.StoreID, params.VendorID, payload, params.Ctx.GetUserName()) - } - return retVal, "", err - }) -} - -// @Title 新增门店映射信息 -// @Description 新增门店映射信息 -// @Param token header string true "认证token" -// @Param storeID formData int true "门店ID,payload中的相应字段会被忽略" -// @Param vendorID formData int true "厂商ID,payload中的相应字段会被忽略" -// @Param vendorOrgCode formData string false "厂商内组织代码" -// @Param payload formData string true "json数据,storeMap对象({'vendorStoreID':'11732425','autoPickup':1,'deliveryCompetition':1, 'pricePercentage':100})" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddStoreVendorMap [post] -func (c *StoreController) AddStoreVendorMap() { - c.callAddStoreVendorMap(func(params *tStoreAddStoreVendorMapParams) (retVal interface{}, errCode string, err error) { - storeMap := &model.StoreMap{} - if err = utils.UnmarshalUseNumber([]byte(params.Payload), storeMap); err == nil { - retVal, err = cms.AddStoreVendorMap(params.Ctx, nil, params.VendorID, params.VendorOrgCode, params.StoreID, storeMap) - } - return retVal, "", err - }) -} - -// @Title 删除门店映射信息 -// @Description 删除门店映射信息 -// @Param token header string true "认证token" -// @Param storeID query int true "门店ID" -// @Param vendorID query int true "厂商ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteStoreVendorMap [delete] -func (c *StoreController) DeleteStoreVendorMap() { - c.callDeleteStoreVendorMap(func(params *tStoreDeleteStoreVendorMapParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.DeleteStoreVendorMap(params.Ctx, nil, params.StoreID, params.VendorID, params.Ctx.GetUserName()) - return retVal, "", err - }) -} - -// @Title 得到门店差评总数 -// @Description 得到门店差评总数,此函数为兼容老系统,之后会被替换 -// @Param token header string true "认证token" -// @Param jxStoreId query int true "门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TmpGetJxBadCommentsNo [get] -func (c *StoreController) TmpGetJxBadCommentsNo() { - c.callTmpGetJxBadCommentsNo(func(params *tStoreTmpGetJxBadCommentsNoParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.TmpGetJxBadCommentsNo(params.Ctx, params.JxStoreId) - return retVal, "", err - }) -} - -// @Title 得到门店评价列表 -// @Description 得到门店评价列表 -// @Param token header string true "认证token" -// @Param jxStoreId query int true "门店ID" -// @Param type query int true "评论类型,0:差评,1:所有" -// @Param page query int true "起始页,从1开始" -// @Param size query int true "页大小(-1表示无限大)" -// @Param fromTime query string false "创建起始时间" -// @Param toTime query string false "创建结束时间" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TmpGetJxBadCommentsByStoreId [get] -func (c *StoreController) TmpGetJxBadCommentsByStoreId() { - c.callTmpGetJxBadCommentsByStoreId(func(params *tStoreTmpGetJxBadCommentsByStoreIdParams) (retVal interface{}, errCode string, err error) { - timeList, err2 := jxutils.BatchStr2Time(params.FromTime, params.ToTime) - if err = err2; err == nil { - pageSize := jxutils.FormalizePageSize(params.Size) - offset := (params.Page - 1) * pageSize - retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, "", []int{params.JxStoreId}, offset, pageSize, params.Type, timeList[0], timeList[1]) - } - return retVal, "", err - }) -} - -// @Title 得到门店评价列表(多店) -// @Description 得到门店评价列表(多店) -// @Param token header string true "认证token" -// @Param type query int true "评论类型,0:差评,1:所有,2:已解决" -// @Param keyword query string false "关键字" -// @Param storeIDs query string false "门店I列表" -// @Param fromTime query string false "创建起始时间" -// @Param toTime query string false "创建结束时间" -// @Param offset query int false "起始页,从1开始" -// @Param pageSize query int false "页大小(-1表示无限大)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TmpGetJxBadComments [get] -func (c *StoreController) TmpGetJxBadComments() { - c.callTmpGetJxBadComments(func(params *tStoreTmpGetJxBadCommentsParams) (retVal interface{}, errCode string, err error) { - var storeIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil { - timeList, err2 := jxutils.BatchStr2Time(params.FromTime, params.ToTime) - if err = err2; err == nil { - retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, params.Keyword, storeIDs, params.Offset, params.PageSize, params.Type, timeList[0], timeList[1]) - } - } - return retVal, "", err - }) -} - -// @Title 得到门店快递映射信息 -// @Description 得到门店快递映射信息 -// @Param token header string true "认证token" -// @Param storeID query int true "门店ID" -// @Param vendorID query int false "厂商ID(缺省为全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreCourierMaps [get] -func (c *StoreController) GetStoreCourierMaps() { - c.callGetStoreCourierMaps(func(params *tStoreGetStoreCourierMapsParams) (retVal interface{}, errCode string, err error) { - if c.GetString("vendorID") == "" { - params.VendorID = -1 - } - retVal, err = cms.GetStoreCourierMaps(params.Ctx, nil, params.StoreID, params.VendorID) - return retVal, "", err - }) -} - -// @Title 修改门店快递映射信息 -// @Description 修改门店快递映射信息 -// @Param token header string true "认证token" -// @Param storeID formData int true "门店ID,payload中的相应字段会被忽略" -// @Param vendorID formData int true "快递厂商ID,payload中的相应字段会被忽略" -// @Param payload formData string true "json数据,StoreCourierMap对象(当前只有status, vendorStoreId两项)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateStoreCourierMap [put] -func (c *StoreController) UpdateStoreCourierMap() { - c.callUpdateStoreCourierMap(func(params *tStoreUpdateStoreCourierMapParams) (retVal interface{}, errCode string, err error) { - storeCourierMap := make(map[string]interface{}) - if err = utils.UnmarshalUseNumber([]byte(params.Payload), &storeCourierMap); err == nil { - retVal, err = cms.UpdateStoreCourierMap(params.Ctx, nil, params.StoreID, params.VendorID, storeCourierMap, params.Ctx.GetUserName()) - } - return retVal, "", err - }) -} - -// @Title 新增门店快递映射信息 -// @Description 新增门店快递映射信息 -// @Param token header string true "认证token" -// @Param storeID formData int true "门店ID,payload中的相应字段会被忽略" -// @Param vendorID formData int true "快递厂商ID,payload中的相应字段会被忽略" -// @Param payload formData string true "json数据,StoreCourierMap对象(当前只有status, vendorStoreId两项)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddStoreCourierMap [post] -func (c *StoreController) AddStoreCourierMap() { - c.callAddStoreCourierMap(func(params *tStoreAddStoreCourierMapParams) (retVal interface{}, errCode string, err error) { - storeCourierMap := &model.StoreCourierMap{} - if err = utils.UnmarshalUseNumber([]byte(params.Payload), storeCourierMap); err == nil { - retVal, err = cms.AddStoreCourierMap(params.Ctx, nil, params.StoreID, params.VendorID, storeCourierMap) - } - return retVal, "", err - }) -} - -// @Title 删除门店快递映射信息 -// @Description 删除门店快递映射信息 -// @Param token header string true "认证token" -// @Param storeID query int true "门店ID" -// @Param vendorID query int true "快递厂商ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteStoreCourierMap [delete] -func (c *StoreController) DeleteStoreCourierMap() { - c.callDeleteStoreCourierMap(func(params *tStoreDeleteStoreCourierMapParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.DeleteStoreCourierMap(params.Ctx, nil, params.StoreID, params.VendorID, params.Ctx.GetUserName()) - return retVal, "", err - }) -} - -// @Title 自动创建或更新快递门店 -// @Description 自动创建或更新快递门店 -// @Param token header string true "认证token" -// @Param storeID formData int false "门店ID" -// @Param isForceUpdate formData bool false "是否强制更新" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateOrCreateCourierStores [put] -func (c *StoreController) UpdateOrCreateCourierStores() { - c.callUpdateOrCreateCourierStores(func(params *tStoreUpdateOrCreateCourierStoresParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.UpdateOrCreateCourierStores(params.Ctx, params.StoreID, params.IsForceUpdate, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 导出门店健康度信息 -// @Description 导出门店健康度信息 -// @Param token header string true "认证token" -// @Param vendorIDs query string false "平台ID列表" -// @Param storeIDs query string false "门店ID列表" -// @Param isAsync query bool false "是否异步操作" -// @Param isContinueWhenError query bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ExportShopsHealthInfo [get] -func (c *StoreController) ExportShopsHealthInfo() { - c.callExportShopsHealthInfo(func(params *tStoreExportShopsHealthInfoParams) (retVal interface{}, errCode string, err error) { - var vendorIDList, storeIDList []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList); err == nil { - retVal, err = cms.ExportShopsHealthInfo(params.Ctx, vendorIDList, storeIDList, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 得到工商执照企业信息 -// @Description 得到工商执照企业信息 -// @Param token header string true "认证token" -// @Param licenceCode query string true "营业执照号" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetCorporationInfo [get] -func (c *StoreController) GetCorporationInfo() { - c.callGetCorporationInfo(func(params *tStoreGetCorporationInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetCorporationInfo(params.Ctx, params.LicenceCode) - return retVal, "", err - }) -} - -// @Title 门店绑定打印 -// @Description 门店绑定打印 -// @Param token header string true "认证token" -// @Param storeID formData int true "京西门店ID" -// @Param data formData string true "原始数据" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /BindPrinter [post] -func (c *StoreController) BindPrinter() { - c.callBindPrinter(func(params *tStoreBindPrinterParams) (retVal interface{}, errCode string, err error) { - retVal, err = netprinter.BindPrinter(params.Ctx, params.StoreID, params.Data) - return retVal, "", err - }) -} - -// @Title 同步门店资质信息至平台(当前只支持京东) -// @Description 同步门店资质信息至平台(当前只支持京东) -// @Param token header string true "认证token" -// @Param storeIDs formData string true "京西门店ID列表,必须非空值" -// @Param isAsync formData bool true "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncStoresQualify [post] -func (c *StoreController) SyncStoresQualify() { - c.callSyncStoresQualify(func(params *tStoreSyncStoresQualifyParams) (retVal interface{}, errCode string, err error) { - var storeIDs []int - err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs) - if err == nil { - retVal, err = cms.SyncStoresQualify(params.Ctx, storeIDs, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 门店评分 -// @Description 门店评分 -// @Param token header string true "认证token" -// @Param storeIDs formData string false "京西门店ID列表" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ScoreStore [post] -func (c *StoreController) ScoreStore() { - c.callScoreStore(func(params *tStoreScoreStoreParams) (retVal interface{}, errCode string, err error) { - var storeIDList []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil { - misc.ScoreStore(params.Ctx, storeIDList) - } - - return retVal, "", err - }) -} - -// @Title 得到门店近期周平均分数数据 -// @Description 得到门店近期周平均分数数据 -// @Param token header string true "认证token" -// @Param storeID query int true "京西门店ID" -// @Param weekIndex query int true "周索引(起始索引为0, -1为所有周数据)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetWeeklyStoreScore [get] -func (c *StoreController) GetWeeklyStoreScore() { - c.callGetWeeklyStoreScore(func(params *tStoreGetWeeklyStoreScoreParams) (retVal interface{}, errCode string, err error) { - retVal, err = misc.GetWeeklyStoreScore(params.StoreID, params.WeekIndex) - return retVal, "", err - }) -} - -// @Title 得到门店总分排名 -// @Description 得到门店总分排名 -// @Param token header string true "认证token" -// @Param storeIDs formData string false "京西门店ID列表" -// @Param cityCode formData int false "城市编码" -// @Param keyword formData string false "关键字" -// @Param beginTime formData string true "开始日期" -// @Param endTime formData string true "结束日期" -// @Param isDesc formData bool true "是否降序" -// @Param checkScoreLow formData int false "在某个分数范围-低" -// @Param checkScoreHigh formData int false "在某个分数范围-高" -// @Param offset formData int false "列表起始序号(以0开始,缺省为0)" -// @Param pageSize formData int false "列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreTotalScoreList [post] -func (c *StoreController) GetStoreTotalScoreList() { - c.callGetStoreTotalScoreList(func(params *tStoreGetStoreTotalScoreListParams) (retVal interface{}, errCode string, err error) { - timeList, err := jxutils.BatchStr2Time(params.BeginTime, params.EndTime) - if err == nil { - var storeIDList []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil { - retVal, err = misc.GetStoreTotalScoreList(storeIDList, params.CityCode, params.Keyword, timeList[0], timeList[1], params.IsDesc, params.CheckScoreLow, params.CheckScoreHigh, params.Offset, params.PageSize) - } - } - return retVal, "", err - }) -} - -// @Title 得到门店触犯红线/黄线数据 -// @Description 得到门店触犯红线/黄线数据 -// @Param token header string true "认证token" -// @Param storeIDs formData string false "京西门店ID列表" -// @Param cityCode formData int false "城市编码" -// @Param keyword formData string false "关键字" -// @Param dateTime formData string true "统计日期" -// @Param offset formData int false "列表起始序号(以0开始,缺省为0)" -// @Param pageSize formData int false "列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreAlertList [post] -func (c *StoreController) GetStoreAlertList() { - c.callGetStoreAlertList(func(params *tStoreGetStoreAlertListParams) (retVal interface{}, errCode string, err error) { - timeList, err := jxutils.BatchStr2Time(params.DateTime) - if err == nil { - var storeIDList []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil { - retVal, err = misc.GetStoreAlertList(storeIDList, params.CityCode, params.Keyword, timeList[0], params.Offset, params.PageSize) - } - } - return retVal, "", err - }) -} - -// @Title 同步快递平台门店信息并报警 -// @Description 同步快递平台门店信息并报警 -// @Param token header string true "认证token" -// @Param storeIDs formData string false "京西门店ID列表,必须非空值" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncStoresCourierInfo [post] -func (c *StoreController) SyncStoresCourierInfo() { - c.callSyncStoresCourierInfo(func(params *tStoreSyncStoresCourierInfoParams) (retVal interface{}, errCode string, err error) { - var storeIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil { - retVal, err = cms.SyncStoresCourierInfo(params.Ctx, storeIDs, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 根据位置得到推荐门店列表 -// @Description 根据位置得到推荐门店列表 -// @Param token header string false "认证token" -// @Param lng query float64 true "经度" -// @Param lat query float64 true "纬度" -// @Param needWalkDistance query bool false "是否需要返回步行距离(且以步行距离排序)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreListByLocation [get] -func (c *StoreController) GetStoreListByLocation() { - c.callGetStoreListByLocation(func(params *tStoreGetStoreListByLocationParams) (retVal interface{}, errCode string, err error) { - retVal, err = common.GetStoreListByLocation(params.Ctx, params.Lng, params.Lat, 20000, params.NeedWalkDistance, false) - return retVal, "", err - }) -} - -// @Title 老格恢复拓店进度 -// @Description 老格恢复拓店进度 -// @Param token header string true "认证token" -// @Param vendorOrgCode formData string false "厂商内组织代码" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /JdStoreInfoCoordinateRecover [post] -func (c *StoreController) JdStoreInfoCoordinateRecover() { - c.callJdStoreInfoCoordinateRecover(func(params *tStoreJdStoreInfoCoordinateRecoverParams) (retVal interface{}, errCode string, err error) { - r := c.Ctx.Request - files := r.MultipartForm.File["userfiles"] - err = cms.JdStoreInfoCoordinateRecover(params.Ctx, params.VendorOrgCode, files) - return retVal, "", err - }) -} - -// @Title 导出平台门店信息 -// @Description 导出平台门店信息 -// @Param token header string true "认证token" -// @Param vendorIDs formData string true "平台ID列表" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetVendorStoreInfo [post] -func (c *StoreController) GetVendorStoreInfo() { - var vendorIDList []int - c.callGetVendorStoreInfo(func(params *tStoreGetVendorStoreInfoParams) (retVal interface{}, errCode string, err error) { - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList); err == nil { - retVal, err = cms.GetVendorStoreInfo(params.Ctx, vendorIDList, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 查询门店价格评分 -// @Description 查询门店价格评分 -// @Param token header string true "认证token" -// @Param storeIDs formData string false "门店列表" -// @Param vendorIDs formData string false "厂商列表" -// @Param snapDate formData string true "时间,默认前一天(格式2006-01-02" -// @Param fromScore formData int false "分数范围开始 默认0" -// @Param toScore formData int false "分数范围结束 默认100" -// @Param sort formData int false "分数排序,-1降序,-升序 ,直降排序,-2降序,2升序,秒杀排序,-3降序,3升序" -// @Param offset formData int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize formData int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStorePriceScore [post] -func (c *StoreController) GetStorePriceScore() { - var storeIDList, vendorIDList []int - c.callGetStorePriceScore(func(params *tStoreGetStorePriceScoreParams) (retVal interface{}, errCode string, err error) { - if jxutils.Strings2Objs(params.StoreIDs, &storeIDList, params.VendorIDs, &vendorIDList); err == nil { - retVal, err = cms.GetStorePriceScore(params.Ctx, storeIDList, vendorIDList, params.FromScore, params.ToScore, params.Sort, params.SnapDate, params.Offset, params.PageSize) - } - return retVal, "", err - }) -} - -// @Title 生成门店价格分数表 -// @Description 生成门店价格分数表 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateStorePriceScore [post] -func (c *StoreController) CreateStorePriceScore() { - c.callCreateStorePriceScore(func(params *tStoreCreateStorePriceScoreParams) (retVal interface{}, errCode string, err error) { - err = cms.CreateStorePriceScore(params.Ctx) - return retVal, "", err - }) -} - -// @Title 刷新store_map的京东等级 -// @Description 刷新store_map的京东等级 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshJdLevel [post] -func (c *StoreController) RefreshJdLevel() { - c.callRefreshJdLevel(func(params *tStoreRefreshJdLevelParams) (retVal interface{}, errCode string, err error) { - err = cms.RefreshJdLevel(params.Ctx) - return retVal, "", err - }) -} - -// @Title 同步指定京东门店 -// @Description 同步京东门店 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncJdStore [post] -func (c *StoreController) SyncJdStore() { - c.callSyncJdStore(func(params *tStoreSyncJdStoreParams) (retVal interface{}, errCode string, err error) { - err = cms.UpdateJdStoreNameAll(params.Ctx) - return retVal, "", err - }) -} - -// @Title 清空打印机打印队列 -// @Description 清空打印机打印队列 -// @Param token header string true "认证token" -// @Param storeIDs formData string true "门店列表" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeletePrinterSeq [post] -func (c *StoreController) DeletePrinterSeq() { - var storeIDList []int - c.callDeletePrinterSeq(func(params *tStoreDeletePrinterSeqParams) (retVal interface{}, errCode string, err error) { - if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil { - err = cms.DeletePrinterSeq(params.Ctx, storeIDList) - } - return retVal, "", err - }) -} - -// @Title 得到门店类别 -// @Description 得到门店类别 -// @Param token header string true "认证token" -// @Param parentID query int false "父ID" -// @Param level query int false "分类等级" -// @Param storeID query int true "门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreCategoryMap [get] -func (c *StoreController) GetStoreCategoryMap() { - c.callGetStoreCategoryMap(func(params *tStoreGetStoreCategoryMapParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetStoreCategoryMap(params.Ctx, params.ParentID, params.Level, params.StoreID) - return retVal, "", err - }) -} - -// @Title 新增门店类别 -// @Description 新增门店类别 -// @Param token header string true "认证token" -// @Param storeID formData int true "门店ID" -// @Param categroyID formData int false "京西分类id" -// @Param level formData int true "分类级别" -// @Param parentID formData int true "分类父ID" -// @Param storeCategroyName formData string true "类别name" -// @Param storeCategroySeq formData int true "类别序号" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddStoreCategoryMap [post] -func (c *StoreController) AddStoreCategoryMap() { - c.callAddStoreCategoryMap(func(params *tStoreAddStoreCategoryMapParams) (retVal interface{}, errCode string, err error) { - storeCategoryMap := &model.StoreCategoryMap{ - StoreID: params.StoreID, - CategoryID: params.CategroyID, - StoreCategoryName: params.StoreCategroyName, - StoreCategorySeq: params.StoreCategroySeq, - Level: params.Level, - ParentID: params.ParentID, - } - retVal, err = cms.AddStoreCategoryMap(params.Ctx, storeCategoryMap) - return retVal, "", err - }) -} - -// @Title 修改门店类别 -// @Description 修改门店类别 -// @Param token header string true "认证token" -// @Param ID formData int true "记录ID" -// @Param categoryID formData int false "京西分类id" -// @Param storeCategroyName formData string false "类别name" -// @Param level formData int true "分类级别" -// @Param parentID formData int true "分类父ID" -// @Param isDelete formData bool false "是否是删除操作,默认false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateStoreCategoryMap [put] -func (c *StoreController) UpdateStoreCategoryMap() { - c.callUpdateStoreCategoryMap(func(params *tStoreUpdateStoreCategoryMapParams) (retVal interface{}, errCode string, err error) { - storeCategoryMap := &model.StoreCategoryMap{ - CategoryID: params.CategoryID, - StoreCategoryName: params.StoreCategroyName, - Level: params.Level, - ParentID: params.ParentID, - } - retVal, err = cms.UpdateStoreCategoryMap(params.Ctx, params.ID, storeCategoryMap, params.IsDelete) - return retVal, "", err - }) -} - -// @Title 门店类别重排序 -// @Description 门店类别重排序 -// @Param token header string true "认证token" -// @Param categoryID formData int true "父ID" -// @Param storeID formData int true "门店ID" -// @Param categoryIDs formData string true "同一父类别下的所有子类别ID列表([1,2,3,4])" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ReorderStoreCategories [put] -func (c *SkuController) ReorderStoreCategories() { - c.callReorderStoreCategories(func(params *tSkuReorderStoreCategoriesParams) (retVal interface{}, errCode string, err error) { - var idList []int - if err = utils.UnmarshalUseNumber([]byte(params.CategoryIDs), &idList); err == nil { - err = cms.ReorderStoreCategories(params.Ctx, params.CategoryID, params.StoreID, idList) - } - return retVal, "", err - }) -} - -// @Title 复制门店类别 -// @Description 复制门店类别 -// @Param token header string true "认证token" -// @Param fromStoreID formData int true "源门店ID" -// @Param toStoreIDs formData string true "目标门店的IDs" -// @Param categoryIDs formData string false "原门店的分类IDs,不传代表整个复制" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CopyStoreCategories [put] -func (c *SkuController) CopyStoreCategories() { - var toStoreIDs, categoryIDs []int - c.callCopyStoreCategories(func(params *tSkuCopyStoreCategoriesParams) (retVal interface{}, errCode string, err error) { - if jxutils.Strings2Objs(params.ToStoreIDs, &toStoreIDs, params.CategoryIDs, &categoryIDs); err == nil { - retVal, err = cms.CopyStoreCategories(params.Ctx, params.FromStoreID, toStoreIDs, categoryIDs, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 修改门店专属调价包 -// @Description 修改门店专属调价包 -// @Param token header string true "认证token" -// @Param storeID formData int true "门店ID" -// @Param vendorID formData int true "平台ID" -// @Param pricePack formData string true "门店调价包" -// @Param value formData string false "调价包json串" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateStorePricePack [put] -func (c *StoreController) UpdateStorePricePack() { - c.callUpdateStorePricePack(func(params *tStoreUpdateStorePricePackParams) (retVal interface{}, errCode string, err error) { - err = cms.UpdateStorePricePack(params.Ctx, params.StoreID, params.VendorID, params.PricePack, params.Value) - return retVal, "", err - }) -} - -// @Title 根据门店获取距离最近的货源店铺 -// @Description 修根据门店获取距离最近的货源店铺 -// @Param token header string true "认证token" -// @Param storeID query int true "门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetNearSupplyGoodsStoreByStoreID [get] -func (c *StoreController) GetNearSupplyGoodsStoreByStoreID() { - c.callGetNearSupplyGoodsStoreByStoreID(func(params *tStoreGetNearSupplyGoodsStoreByStoreIDParams) (retVal interface{}, errCode string, err error) { - retVal, err = common.GetNearSupplyGoodsStoreByStoreID(params.Ctx, params.StoreID) - return retVal, "", err - }) -} - -// @Title 获取京东门店手动划的配送范围面积 -// @Description 获取京东门店手动划的配送范围面积 -// @Param token header string true "认证token" -// @Param storeIDs query string true "门店IDs" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetJdDeliveryArea [get] -func (c *StoreController) GetJdDeliveryArea() { - var storeIDs []int - c.callGetJdDeliveryArea(func(params *tStoreGetJdDeliveryAreaParams) (retVal interface{}, errCode string, err error) { - if jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil { - err = cms.GetJdDeliveryArea(params.Ctx, storeIDs) - } - return retVal, "", err - }) -} - -// @Title 修改门店对应Cid(个推推送uniapp消息用) -// @Description 修改门店对应Cid(个推推送uniapp消息用) -// @Param token header string true "认证token" -// @Param storeID formData int true "门店ID" -// @Param clientID formData string true "cID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateStorePushClient [post] -func (c *StoreController) UpdateStorePushClient() { - c.callUpdateStorePushClient(func(params *tStoreUpdateStorePushClientParams) (retVal interface{}, errCode string, err error) { - err = cms.UpdateStorePushClient(params.Ctx, params.StoreID, params.ClientID) - return retVal, "", err - }) -} - -// @Title 用户申请门店审核 -// @Description 用户申请门店审核 -// @Param token header string true "认证token" -// @Param payload formData string true "json数据,store对象" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateStoreAudit [post] -func (c *StoreController) CreateStoreAudit() { - c.callCreateStoreAudit(func(params *tStoreCreateStoreAuditParams) (retVal interface{}, errCode string, err error) { - store := &model.StoreAudit{} - if err = utils.UnmarshalUseNumber([]byte(params.Payload), store); err == nil { - err = cms.CreateStoreAudit(params.Ctx, store) - } - return retVal, "", err - }) -} - -// @Title 获取用户申请门店审核 -// @Description 获取用户申请门店审核 -// @Param token header string true "认证token" -// @Param applyTimeStart query string false "申请开始时间" -// @Param applyTimeEnd query string false "申请结束时间" -// @Param auditTimeStart query string false "审核开始时间" -// @Param auditTimeEnd query string false "审核结束时间" -// @Param name query string false "审核人" -// @Param statuss query string false "审核状态" -// @Param keyword query string false "关键字" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreAudit [get] -func (c *StoreController) GetStoreAudit() { - c.callGetStoreAudit(func(params *tStoreGetStoreAuditParams) (retVal interface{}, errCode string, err error) { - var ( - statuss []int - ) - if err = jxutils.Strings2Objs(params.Statuss, &statuss); err != nil { - return retVal, "", err - } - retVal, err = cms.GetStoreAudit(params.Ctx, statuss, params.Keyword, params.ApplyTimeStart, params.ApplyTimeEnd, params.AuditTimeStart, params.AuditTimeEnd, params.PageSize, params.Offset) - return retVal, "", err - }) -} - -// @Title 门店审核 -// @Description 门店审核 -// @Param token header string true "认证token" -// @Param payload formData string true "json数据,storeaudit对象" -// @Param status formData int false "审核标志,1通过,-1 不通过" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /StoreAudit [post] -func (c *StoreController) StoreAudit() { - c.callStoreAudit(func(params *tStoreStoreAuditParams) (retVal interface{}, errCode string, err error) { - var stores []*model.StoreAudit - if err = utils.UnmarshalUseNumber([]byte(params.Payload), &stores); err == nil { - retVal, err = cms.StoreAudit(params.Ctx, stores, params.Status) - } - return retVal, "", err - }) -} - -// @Title 比较美团配送门店信息 -// @Description 比较美团配送门店信息 -// @Param token header string true "认证token" -// @Param storeIDs formData string true "门店ids" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetDiffJxStoreAndMTWMStoreInfo [post] -func (c *StoreController) GetDiffJxStoreAndMTWMStoreInfo() { - c.callGetDiffJxStoreAndMTWMStoreInfo(func(params *tStoreGetDiffJxStoreAndMTWMStoreInfoParams) (retVal interface{}, errCode string, err error) { - var storeIDs []int - if err = utils.UnmarshalUseNumber([]byte(params.StoreIDs), &storeIDs); err == nil { - err = cms.GetDiffJxStoreAndMTWMStoreInfo(params.Ctx, storeIDs) - } - return retVal, "", err - }) -} diff --git a/controllers/cms_sync.go b/controllers/cms_sync.go deleted file mode 100644 index 3b15447e4..000000000 --- a/controllers/cms_sync.go +++ /dev/null @@ -1,387 +0,0 @@ -package controllers - -import ( - "fmt" - "io" - - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/model/dao" - "github.com/astaxie/beego" -) - -type SyncController struct { - beego.Controller -} - -// @Title 同步商家商品信息 -// @Description 同步商家商品信息 -// @Param token header string true "认证token" -// @Param storeIDs formData string true "门店ID列表" -// @Param vendorIDs formData string true "厂商ID列表" -// @Param skuIDs formData string false "SKU ID列表,缺省为全部" -// @Param isForce formData bool false "是否强制(设置修改标志)" -// @Param isAsync formData bool true "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncStoresSkus [put] -func (c *SyncController) SyncStoresSkus() { - c.callSyncStoresSkus(func(params *tSyncSyncStoresSkusParams) (retVal interface{}, errCode string, err error) { - db := dao.GetDB() - var storeIDs, skuIDs, vendorIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs, params.VendorIDs, &vendorIDs); err != nil { - return retVal, "", err - } - retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, nil, 0, db, vendorIDs, storeIDs, skuIDs, params.IsForce, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 同步商家分类信息 -// @Description 同步商家分类信息 -// @Param token header string true "认证token" -// @Param storeIDs formData string true "门店ID列表" -// @Param vendorIDs formData string true "厂商ID列表" -// @Param isForce formData bool false "是否强制(设置修改标志)" -// @Param isAsync formData bool true "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncStoresCategory [put] -func (c *SyncController) SyncStoresCategory() { - c.callSyncStoresCategory(func(params *tSyncSyncStoresCategoryParams) (retVal interface{}, errCode string, err error) { - db := dao.GetDB() - var storeIDs, vendorIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil { - return retVal, "", err - } - retVal, err = cms.CurVendorSync.SyncStoresCategory(params.Ctx, db, vendorIDs, storeIDs, params.IsForce, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 全部刷新所有门店商家ID -// @Description 全部刷新所有门店商家ID -// @Param token header string true "认证token" -// @Param vendorIDs query string true "需要刷新的厂商ID列表" -// @Param isAsync query bool false "起始状态" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshAllStoresID [put] -func (c *SyncController) RefreshAllStoresID() { - c.callRefreshAllStoresID(func(params *tSyncRefreshAllStoresIDParams) (retVal interface{}, errCode string, err error) { - var vendorIDs []int - if err = utils.UnmarshalUseNumber([]byte(params.VendorIDs), &vendorIDs); err != nil { - return retVal, "", err - } - retVal, err = cms.CurVendorSync.RefreshAllStoresID(params.Ctx, params.IsAsync, vendorIDs) - return retVal, "", err - }) -} - -// @Title 重新刷新商家SKU ID -// @Description 重新刷新商家SKU ID,单门店厂商必须指定storeIDs -// @Param token header string true "认证token" -// @Param vendorIDs query string true "需要刷新的厂商ID列表" -// @Param storeIDs query string false "需要刷新的门店ID列表(对于单门店必须指定)" -// @Param isAsync query bool false "起始状态" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshAllSkusID [put] -// func (c *SyncController) RefreshAllSkusID() { -// c.callRefreshAllSkusID(func(params *tSyncRefreshAllSkusIDParams) (retVal interface{}, errCode string, err error) { -// var vendorIDs, storeIDs []int -// if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil { -// return retVal, "", err -// } -// retVal, err = cms.CurVendorSync.RefreshAllSkusID(params.Ctx, params.IsAsync, vendorIDs, storeIDs) -// return retVal, "", err -// }) -// } - -// @Title 全新初始化商家商品信息 -// @Description 全新初始化商家商品信息(!!!此操作会先清除平台上已有的商品及分类信息),此操作只适用于单门店模式平台 -// @Param token header string true "认证token" -// @Param storeIDs formData string true "门店ID列表" -// @Param vendorIDs formData string true "厂商ID列表" -// @Param isAsync formData bool true "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /FullSyncStoresSkus [put] -func (c *SyncController) FullSyncStoresSkus() { - c.callFullSyncStoresSkus(func(params *tSyncFullSyncStoresSkusParams) (retVal interface{}, errCode string, err error) { - db := dao.GetDB() - var vendorIDs, storeIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil { - return retVal, "", err - } - retVal, err = cms.CurVendorSync.FullSyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, true, nil, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 删除门店平台商品信息(包括分类) -// @Description 删除门店平台商品信息(包括分类)(!!!此操作会先清除平台上已有的商品及分类信息),此操作只适用于单门店模式平台 -// @Param token header string true "认证token" -// @Param storeIDs query string true "门店ID列表" -// @Param vendorIDs query string true "厂商ID列表" -// @Param isAsync query bool true "是否异步操作" -// @Param isContinueWhenError query bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteRemoteStoreSkus [delete] -func (c *SyncController) DeleteRemoteStoreSkus() { - c.callDeleteRemoteStoreSkus(func(params *tSyncDeleteRemoteStoreSkusParams) (retVal interface{}, errCode string, err error) { - db := dao.GetDB() - var vendorIDs, storeIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil { - return retVal, "", err - } - retVal, err = cms.CurVendorSync.DeleteRemoteStoreSkus(params.Ctx, db, vendorIDs, storeIDs, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 同步门店 -// @Description 同步门店 -// @Param token header string true "认证token" -// @Param vendorIDs formData string false "平台ID(京东0 美团1 饿百3)列表" -// @Param vendorOrgCodes formData string false "平台账号列表" -// @Param storeIDs formData string false "门店ID列表" -// @Param isForce formData bool false "是否强制(设置修改标志)" -// @Param isAsync formData bool false "是否异步" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncStores [post] -func (c *SyncController) SyncStores() { - c.callSyncStores(func(params *tSyncSyncStoresParams) (retVal interface{}, errCode string, err error) { - var vendorIDs, storeIDs []int - var vendorOrgCodes []string - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs, params.StoreIDs, &storeIDs, params.VendorOrgCodes, &vendorOrgCodes); err == nil { - db := dao.GetDB() - if params.IsForce { - dao.SetStoreMapSyncStatus(db, vendorIDs, storeIDs, model.SyncFlagModifiedMask) - } - retVal, err = cms.CurVendorSync.SyncStore2(params.Ctx, db, vendorIDs, storeIDs, true, params.IsAsync) - } - return retVal, "", err - }) -} - -// @Title 同步商家分类(多门店平台) -// @Description 同步商家分类(多门店平台) -// @Param token header string true "认证token" -// @Param vendorID formData int false "平台ID(京东0 美团1 饿百3)" -// @Param vendorOrgCode formData string false "平台账号" -// @Param isForce formData bool false "是否强制(设置修改标志)" -// @Param isAsync formData bool false "是否异步" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncCategories [post] -func (c *SyncController) SyncCategories() { - c.callSyncCategories(func(params *tSyncSyncCategoriesParams) (retVal interface{}, errCode string, err error) { - var vendorIDs []int - if params.MapData["vendorID"] != nil { - vendorIDs = append(vendorIDs, params.VendorID) - } - vendorOrgCodes := jxutils.BatchString2Slice(params.VendorOrgCode) - if params.IsForce { - dao.SetThingMapSyncStatus(dao.GetDB(), vendorIDs, vendorOrgCodes, model.ThingTypeCategory, nil, model.SyncFlagModifiedMask) - } - retVal, err = cms.SyncCategories(params.Ctx, nil, vendorIDs, vendorOrgCodes, nil, params.IsAsync) - return retVal, "", err - }) -} - -// @Title 同步SkuName(多门店平台) -// @Description 同步SkuName(多门店平台) -// @Param token header string true "认证token" -// @Param nameIDs formData string false "name ID列表" -// @Param isForce formData bool false "是否强制(设置修改标志)" -// @Param vendorID formData int false "平台ID(京东0 美团1 饿百3)" -// @Param vendorOrgCode formData string false "平台账号" -// @Param isAsync formData bool false "是否异步" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncSkuNames [put,post] -func (c *SyncController) SyncSkuNames() { - c.callSyncSkuNames(func(params *tSyncSyncSkuNamesParams) (retVal interface{}, errCode string, err error) { - var nameIDs []int - if err = jxutils.Strings2Objs(params.NameIDs, &nameIDs); err == nil { - var vendorIDs []int - if params.MapData["vendorID"] != nil { - vendorIDs = append(vendorIDs, params.VendorID) - } - vendorOrgCodes := jxutils.BatchString2Slice(params.VendorOrgCode) - if params.IsForce { - dao.SetSkuNameSyncStatus(dao.GetDB(), vendorIDs, vendorOrgCodes, nameIDs, model.SyncFlagModifiedMask) - } - retVal, err = cms.SyncSkus(params.Ctx, nil, vendorIDs, vendorOrgCodes, nameIDs, nil, params.IsAsync) - } - return retVal, "", err - }) -} - -// @Title 删除本地没有的平台门店商品信息 -// @Description 删除本地没有的平台门店商品信息(已废弃) -// @Param token header string true "认证token" -// @Param storeIDs query string true "门店ID列表" -// @Param vendorIDs query string true "厂商ID列表" -// @Param isAsync query bool false "是否异步操作" -// @Param isContinueWhenError query bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /PruneMissingStoreSkus [delete] -func (c *SyncController) PruneMissingStoreSkus() { - c.callPruneMissingStoreSkus(func(params *tSyncPruneMissingStoreSkusParams) (retVal interface{}, errCode string, err error) { - var storeIDs, vendorIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err == nil { - retVal, err = cms.CurVendorSync.PruneMissingStoreSkus(params.Ctx, vendorIDs, storeIDs, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 把京西有,平台无且没有待创建标记的商品加上待创建标记 -// @Description 把京西有,平台无且没有待创建标记的商品加上待创建标记(已废弃) -// @Param token header string true "认证token" -// @Param storeIDs formData string false "门店ID列表" -// @Param vendorIDs formData string false "运营商ID列表(京东0 美团1 饿百3)" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddCreateFlagForJxStoreSku [post] -func (c *SyncController) AddCreateFlagForJxStoreSku() { - c.callAddCreateFlagForJxStoreSku(func(params *tSyncAddCreateFlagForJxStoreSkuParams) (retVal interface{}, errCode string, err error) { - var storeIDs, vendorIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err == nil { - retVal, err = cms.CurVendorSync.AddCreateFlagForJxStoreSku(params.Ctx, vendorIDs, storeIDs, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 把京西有,平台无且没有待创建标记的商品加上待创建标记 -// @Description 把京西有,平台无且没有待创建标记的商品加上待创建标记 -// @Param token header string true "认证token" -// @Param storeIDs formData string false "门店ID列表" -// @Param vendorIDs formData string false "运营商ID列表(京东0 美团1 饿百3)" -// @Param optType formData int true "操作方式" -// @Param isForce formData bool false "是否强制刷新" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AmendAndPruneStoreStuff [post] -func (c *SyncController) AmendAndPruneStoreStuff() { - c.callAmendAndPruneStoreStuff(func(params *tSyncAmendAndPruneStoreStuffParams) (retVal interface{}, errCode string, err error) { - var storeIDs, vendorIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err == nil { - retVal, err = cms.CurVendorSync.AmendAndPruneStoreStuff(params.Ctx, vendorIDs, storeIDs, params.IsAsync, params.IsContinueWhenError, params.OptType, params.IsForce) - } - return retVal, "", err - }) -} - -// @Title 初始化多门店平台商品库(及商家分类) -// @Description 初始化多门店平台商品库(及商家分类) -// @Param token header string true "认证token" -// @Param vendorID formData int true "平台ID(京东0 美团1 饿百3)" -// @Param vendorOrgCode formData string true "平台账号" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /FullSyncVendorStuff [post] -func (c *SyncController) FullSyncVendorStuff() { - c.callFullSyncVendorStuff(func(params *tSyncFullSyncVendorStuffParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.FullSyncVendorStuff(params.Ctx, nil, params.VendorID, params.VendorOrgCode, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 上传假京东门店与SKU映射表(并启动同步) -// @Description 上传假京东门店与SKU映射表(并启动同步) -// @Param token header string false "认证token" -// @Param isSyncNow formData bool false "是否马上同步,一般不建议" -// @Param isAsync formData bool false "是否异步,缺省是同步" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UploadFakeJdThingMap [post,get] -func (c *SyncController) UploadFakeJdThingMap() { - if c.Ctx.Input.IsGet() { - w := c.Ctx.ResponseWriter - // 上传页面 - w.Header().Add("Content-Type", "text/html") - w.WriteHeader(200) - html := ` -
- Send this file: - -
- ` - io.WriteString(w, html) - } else if c.Ctx.Input.IsPost() { - c.callUploadFakeJdThingMap(func(params *tSyncUploadFakeJdThingMapParams) (retVal interface{}, errCode string, err error) { - r := c.Ctx.Request - files := r.MultipartForm.File["userfiles"] - if len(files) == 0 { - err = fmt.Errorf("没上传文件") - } else { - fileReader, err2 := files[0].Open() - if err = err2; err == nil { - retVal, err = cms.UploadFakeJdThingMap(params.Ctx, fileReader, params.IsSyncNow, params.IsAsync, params.IsContinueWhenError) - fileReader.Close() - } - } - return retVal, "", err - }) - } -} - -// @Title 同步银豹到京西商品 -// @Description 同步银豹到京西商品 -// @Param token header string true "认证token" -// @Param storeIDs formData string false "门店ID列表" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncStoreSkusFromYb [put] -func (c *SyncController) SyncStoreSkusFromYb() { - c.callSyncStoreSkusFromYb(func(params *tSyncSyncStoreSkusFromYbParams) (retVal interface{}, errCode string, err error) { - var storeIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil { - retVal, err = cms.CurVendorSync.SyncStoreSkusFromYb(params.Ctx, storeIDs, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 同步京东商城门店商品和库存 -// @Description 同步京东商城门店商品和库存 -// @Param token header string true "认证token" -// @Param storeIDs formData string false "门店ID列表" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SyncJdsStoresSkus [put] -func (c *SyncController) SyncJdsStoresSkus() { - c.callSyncJdsStoresSkus(func(params *tSyncSyncJdsStoresSkusParams) (retVal interface{}, errCode string, err error) { - var storeIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil { - retVal, err = cms.CurVendorSync.SyncJdsStoresSkus(params.Ctx, storeIDs, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} diff --git a/controllers/cms_user.go b/controllers/cms_user.go deleted file mode 100644 index 695674526..000000000 --- a/controllers/cms_user.go +++ /dev/null @@ -1,118 +0,0 @@ -package controllers - -// type UserController struct { -// beego.Controller -// } - -// // @Title 得到门店用户信息 -// // @Description 得到门店用户信息 -// // @Param token header string true "认证token" -// // @Param storeID query int true "门店号" -// // @Success 200 {object} controllers.CallResult -// // @Failure 200 {object} controllers.CallResult -// // @router /TmpGetStoreUsers [get] -// func (c *UserController) TmpGetStoreUsers() { -// c.callTmpGetStoreUsers(func(params *tUserTmpGetStoreUsersParams) (retVal interface{}, errCode string, err error) { -// retVal, err = cms.GetStoreUsers(params.Ctx, params.StoreID) -// return retVal, "", err -// }) -// } - -// // @Title 得到用户门店及成员信息 -// // @Description 得到用户门店及成员信息 -// // @Param token header string true "认证token" -// // @Param mobile query string true "手机号" -// // @Success 200 {object} controllers.CallResult -// // @Failure 200 {object} controllers.CallResult -// // @router /TmpGetUserInfo [get] -// func (c *UserController) TmpGetUserInfo() { -// c.callTmpGetUserInfo(func(params *tUserTmpGetUserInfoParams) (retVal interface{}, errCode string, err error) { -// retVal, err = cms.GetUserInfo(params.Ctx, params.Mobile) -// return retVal, "", err -// }) -// } - -// // @Title 得到用户自己的门店及成员信息 -// // @Description 得到用户自己的门店及成员信息 -// // @Param token header string true "认证token" -// // @Success 200 {object} controllers.CallResult -// // @Failure 200 {object} controllers.CallResult -// // @router /TmpGetSelfInfo [get] -// func (c *UserController) TmpGetSelfInfo() { -// c.callTmpGetSelfInfo(func(params *tUserTmpGetSelfInfoParams) (retVal interface{}, errCode string, err error) { -// retVal, err = cms.GetSelfInfo(params.Ctx) -// return retVal, "", err -// }) -// } - -// // @Title 得到用户自己的门店列表 -// // @Description 得到用户自己的门店列表 -// // @Param token header string true "认证token" -// // @Success 200 {object} controllers.CallResult -// // @Failure 200 {object} controllers.CallResult -// // @router /TmpGetMyStoreList [get] -// func (c *UserController) TmpGetMyStoreList() { -// c.callTmpGetSelfInfo(func(params *tUserTmpGetSelfInfoParams) (retVal interface{}, errCode string, err error) { -// retVal, err = cms.GetMyStoreList(params.Ctx) -// return retVal, "", err -// }) -// } - -// // @Title 取消手机门店绑定 -// // @Description 此操作会将此手机关联的所有门店信息清除(取消组长,取消自己为他组组员),如果此人为组长,取消后组员也相应会取消门店绑定(但组员的成员关系还在) -// // @Param token header string true "认证token" -// // @Param mobile formData string true "手机号" -// // @Success 200 {object} controllers.CallResult -// // @Failure 200 {object} controllers.CallResult -// // @router /TmpUnbindMobile [put] -// func (c *UserController) TmpUnbindMobile() { -// c.callTmpUnbindMobile(func(params *tUserTmpUnbindMobileParams) (retVal interface{}, errCode string, err error) { -// retVal, err = cms.UnbindMobile(params.Ctx, params.Mobile) -// return retVal, "", err -// }) -// } - -// // @Title 手机门店绑定 -// // @Description 此操作会将此手机设置成为相应门的组长,如果之前有组员关系,则此操作后,组员也会自动与门店绑定 -// // @Param token header string true "认证token" -// // @Param mobile formData string true "手机号" -// // @Param storeID formData int true "门店ID" -// // @Success 200 {object} controllers.CallResult -// // @Failure 200 {object} controllers.CallResult -// // @router /TmpBindMobile2Store [put] -// func (c *UserController) TmpBindMobile2Store() { -// c.callTmpBindMobile2Store(func(params *tUserTmpBindMobile2StoreParams) (retVal interface{}, errCode string, err error) { -// retVal, err = cms.BindMobile2Store(params.Ctx, params.Mobile, params.StoreID) -// return retVal, "", err -// }) -// } - -// // @Title 将手机加到另一手机上 -// // @Description 将手机加到另一手机上 -// // @Param token header string true "认证token" -// // @Param parentMobile formData string true "父手机号" -// // @Param mobile formData string true "手机号" -// // @Success 200 {object} controllers.CallResult -// // @Failure 200 {object} controllers.CallResult -// // @router /TmpAddMobile2Mobile [put] -// func (c *UserController) TmpAddMobile2Mobile() { -// c.callTmpAddMobile2Mobile(func(params *tUserTmpAddMobile2MobileParams) (retVal interface{}, errCode string, err error) { -// retVal, err = cms.AddMobile2Mobile(params.Ctx, params.ParentMobile, params.Mobile) -// return retVal, "", err -// }) -// } - -// // @Title 变更手机号 -// // @Description 变更手机号 -// // @Param token header string true "认证token" -// // @Param curMobile formData string true "当前手机号" -// // @Param expectedMobile formData string true "手机号" -// // @Success 200 {object} controllers.CallResult -// // @Failure 200 {object} controllers.CallResult -// // @router /TmpChangeMobile [put] -// func (c *UserController) TmpChangeMobile() { -// c.callTmpChangeMobile(func(params *tUserTmpChangeMobileParams) (retVal interface{}, errCode string, err error) { -// retVal, err = cms.ChangeMobile(params.Ctx, params.CurMobile, params.ExpectedMobile) -// return retVal, "", err -// }) -// } diff --git a/controllers/dada_order.go b/controllers/dada_order.go deleted file mode 100644 index 8635d3fac..000000000 --- a/controllers/dada_order.go +++ /dev/null @@ -1,54 +0,0 @@ -package controllers - -import ( - "net/http" - - "git.rosy.net.cn/baseapi/platformapi/dadaapi" - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/partner/delivery/dada" - "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego" -) - -// Operations about ELMOrder -type DadaDeliveryController struct { - beego.Controller -} - -func (c *DadaDeliveryController) Msg() { - if c.Ctx.Input.Method() == http.MethodPost { - obj, callbackResponse := api.DadaAPI.GetOrderCallbackMsg(c.Ctx.Input.RequestBody) - if callbackResponse == nil { - callbackResponse = dada.OnWaybillMsg(obj) - } - if callbackResponse != nil && callbackResponse.Code != 200 { - c.CustomAbort(callbackResponse.Code, string(utils.MustMarshal(callbackResponse))) - } else { - c.Data["json"] = callbackResponse - c.ServeJSON() - } - } else { - c.Abort("404") - } -} - -func (c *DadaDeliveryController) Notify() { - if c.Ctx.Input.Method() == http.MethodPost { - obj, notifyResponse := api.DadaAPI.GetNotifyMsg(c.Ctx.Input.RequestBody) - if notifyResponse == nil && obj.MessageObj != nil { - err := api.DadaAPI.ConfirmRidderCancel(obj.MessageObj.OrderID, obj.MessageObj.DadaOrderID, true) - if err != nil { - notifyResponse = dadaapi.FailedNotifyResponse - } - globals.SugarLogger.Debugf("dada notify, obj:%s, err:%v", utils.Format4Output(obj, false), err) - } - if notifyResponse == nil { - notifyResponse = dadaapi.SuccessNotifyResponse - } - c.Data["json"] = notifyResponse - c.ServeJSON() - } else { - c.Abort("404") - } -} diff --git a/controllers/dingding_api.go b/controllers/dingding_api.go deleted file mode 100644 index 8082b9044..000000000 --- a/controllers/dingding_api.go +++ /dev/null @@ -1,57 +0,0 @@ -package controllers - -import ( - "crypto/sha1" - "fmt" - "time" - - "git.rosy.net.cn/jx-callback/globals" - - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego" -) - -type DDAPIController struct { - beego.Controller -} - -type DDAPI struct { - Ticket string - ExpiresIn time.Time -} - -var ( - ddapi *DDAPI -) - -func init() { - ddapi = &DDAPI{} -} - -// @Title 得到门店用户信息 -// @Description 得到门店用户信息 -// @Param token header string true "认证token" -// @Param url query string true "当前网页的URL,不包含#及其后面部分" -// @Param nonceStr query string true "随机串,自己定义" -// @Param timeStamp query string true "时间戳" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /Sign [get] -func (c *DDAPIController) Sign() { - c.callSign(func(params *tDdapiSignParams) (retVal interface{}, errCode string, err error) { - if ddapi.Ticket == "" || time.Now().Sub(ddapi.ExpiresIn) >= -5*time.Minute { - expiresIn, ticket, err2 := api.DingDingAPI.GetJSAPITicket("") - if err = err2; err == nil { - ddapi.Ticket = ticket - ddapi.ExpiresIn = time.Now().Add(time.Duration(expiresIn) * time.Second) - } - } - if err == nil { - str := "jsapi_ticket=" + ddapi.Ticket + - "&noncestr=" + params.NonceStr + "×tamp=" + params.TimeStamp + "&url=" + params.Url - retVal = fmt.Sprintf("%x", sha1.Sum([]byte(str))) - globals.SugarLogger.Debugf("dingapi str:%s sign:%v", str, retVal) - } - return retVal, "", err - }) -} diff --git a/controllers/dingding_callback.go b/controllers/dingding_callback.go deleted file mode 100644 index 402c69cd6..000000000 --- a/controllers/dingding_callback.go +++ /dev/null @@ -1,38 +0,0 @@ -package controllers - -import ( - "net/http" - - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego" -) - -type DingDingController struct { - beego.Controller -} - -func init() { - -} - -func (c *DingDingController) Msg() { - globals.SugarLogger.Debugf("dingding msg:%s", string(c.Ctx.Input.RequestBody)) - if c.Ctx.Input.Method() == http.MethodPost { - dataMap := utils.URLValues2Map(c.Ctx.Request.Form) - obj, callbackResponse := api.DingDingAPI.GetCallbackMsg(dataMap, c.Ctx.Input.RequestBody) - if callbackResponse == nil { - globals.SugarLogger.Debugf("dingding msg, obj:%s", utils.Format4Output(obj, false)) - callbackResponse = cms.OnDingDingMsg(dataMap) - if callbackResponse == nil { - callbackResponse = api.DingDingAPI.Err2CallbackResponse(nil) - } - } - c.Data["json"] = callbackResponse - c.ServeJSON() - } else { - c.Abort("404") - } -} diff --git a/controllers/ebai_callback.go b/controllers/ebai_callback.go deleted file mode 100644 index 267109b4a..000000000 --- a/controllers/ebai_callback.go +++ /dev/null @@ -1,30 +0,0 @@ -package controllers - -import ( - "net/http" - - "git.rosy.net.cn/baseapi/platformapi/ebaiapi" - "git.rosy.net.cn/jx-callback/business/partner/purchase/ebai" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego" -) - -type EbaiController struct { - beego.Controller -} - -func (c *EbaiController) Msg() { - if c.Ctx.Input.Method() == http.MethodPost { - obj, callbackResponse := api.EbaiAPI.GetCallbackMsg(c.Ctx.Request) - if callbackResponse == nil { - callbackResponse = ebai.OnCallbackMsg(obj) - } - if callbackResponse == nil { - callbackResponse = api.EbaiAPI.Err2CallbackResponse(ebaiapi.GetCmd(c.Ctx.Request), nil, nil) - } - c.Data["json"] = callbackResponse - c.ServeJSON() - } else { - c.Abort("404") - } -} diff --git a/controllers/eclp_callback.go b/controllers/eclp_callback.go deleted file mode 100644 index 40b0b8635..000000000 --- a/controllers/eclp_callback.go +++ /dev/null @@ -1,22 +0,0 @@ -package controllers - -import ( - "fmt" - "net/http" - - "github.com/astaxie/beego" -) - -type EclpController struct { - beego.Controller -} - -func (c *EclpController) Msg() { - if c.Ctx.Input.Method() == http.MethodPost { - fmt.Println("testElcp", c.Ctx.Request.Body) - c.Data["json"] = c.Ctx.Request.Body - c.ServeJSON() - } else { - c.Abort("404") - } -} diff --git a/controllers/elm_order.go b/controllers/elm_order.go deleted file mode 100644 index d1d24a1a4..000000000 --- a/controllers/elm_order.go +++ /dev/null @@ -1,31 +0,0 @@ -package controllers - -import ( - "net/http" - - "git.rosy.net.cn/baseapi/platformapi/elmapi" - "github.com/astaxie/beego" -) - -// Operations about ELMOrder -type ElemeController struct { - beego.Controller -} - -// https://open.shop.ele.me/openapi/documents/httppushmethod -func (c *ElemeController) Msg() { - if c.Ctx.Input.Method() == http.MethodPost { - callbackResponse := elmapi.SuccessResponse - // obj, callbackResponse := api.ElmAPI.GetCallbackMsg(c.Ctx.Input.RequestBody) - // if callbackResponse == nil { - // callbackResponse = elm.OnCallbackMsg(obj) - // } - c.Data["json"] = callbackResponse - c.ServeJSON() - } else if c.Ctx.Input.Method() == http.MethodGet { // 应用需要支持推送地址的GET访问,当GET请求访问时,请直接返回{“message”:“ok”},用于推送地址的可用性测试。 - c.Data["json"] = elmapi.SuccessResponse - c.ServeJSON() - } else { - c.Abort("404") - } -} diff --git a/controllers/event.go b/controllers/event.go deleted file mode 100644 index ce8349a14..000000000 --- a/controllers/event.go +++ /dev/null @@ -1,230 +0,0 @@ -package controllers - -import ( - "log" - "net/http" - "time" - - "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" - - "git.rosy.net.cn/jx-callback/globals" - - "git.rosy.net.cn/jx-callback/business/model/dao" - - "git.rosy.net.cn/jx-callback/business/model" - - "github.com/gorilla/websocket" - - "git.rosy.net.cn/baseapi/utils" - - "git.rosy.net.cn/jx-callback/business/jxstore/event" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego" -) - -// 操作事件明细相关API -type EventController struct { - beego.Controller -} - -//连接的客户端,吧每个客户端都放进来 -var clients = make(map[string][]*websocket.Conn) - -//广播频道(通道) -var broadcast = make(chan map[string]*model.ImMessageRecord) - -// 配置升级程序(升级为websocket) -var upgrader = websocket.Upgrader{} - -// 定义我们的消息对象 -type Message struct { - Data interface{} `json:"data"` -} - -// @Title 查询操作日志事件明细 -// @Description 查询操作日志事件明细 -// @Param token header string true "认证token" -// @Param apiFunctions query string false "功能名列表" -// @Param name query string false "操作人姓名,支持模糊查询" -// @Param operateTypes query string false "操作类型列表,1为修改,2为新增,4为删除" -// @Param skuIDs query string false "商品ID列表" -// @Param storeIDs query string false "门店ID列表" -// @Param fromTime query string false "开始日期(包含),格式(2006-01-02 00:00:00)" -// @Param toTime query string false "结束日期(包含),格式(2006-01-02 00:00:00)" -// @Param keyword query string false "关键字" -// @Param errType query int false "查询错误日志,默认0都查,1不查错误日志,-1只查错误日志" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为30)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOperateEvents [get] -func (c *EventController) GetOperateEvents() { - var storeIDList, skuIDList, operateTypeList []int - var apiFunctionList []string - c.callGetOperateEvents(func(params *tEventGetOperateEventsParams) (retVal interface{}, errCode string, err error) { - if jxutils.Strings2Objs(params.StoreIDs, &storeIDList, params.SkuIDs, &skuIDList, params.ApiFunctions, &apiFunctionList, params.OperateTypes, &operateTypeList); err == nil { - retVal, err = event.GetOperateEvents(params.Ctx, params.Name, apiFunctionList, operateTypeList, skuIDList, storeIDList, params.FromTime, params.ToTime, params.Keyword, params.ErrType, params.Offset, params.PageSize) - } - return retVal, "", err - }) -} - -// @Title 各平台Cookie检查 -// @Description 各平台Cookie检查 -// @Param token header string true "认证token" -// @Param vendorIDs query string false "平台ID列表" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetCheckVendorCookie [get] -func (c *EventController) GetCheckVendorCookie() { - var vendorIDList []int - c.callGetCheckVendorCookie(func(params *tEventGetCheckVendorCookieParams) (retVal interface{}, errCode string, err error) { - if jxutils.Strings2Objs(params.VendorIDs, &vendorIDList); err == nil { - retVal, err = event.GetCheckVendorCookie(params.Ctx, vendorIDList, false) - } - return retVal, "", err - }) -} - -// @Title 得到微信小程序码 -// @Description 得到微信小程序码 -// @Param token header string true "认证token" -// @Param scene formData string true "最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)" -// @Param page formData string false "必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetWeixinUnlimited [post] -func (c *EventController) GetWeixinUnlimited() { - c.callGetWeixinUnlimited(func(params *tEventGetWeixinUnlimitedParams) (retVal interface{}, errCode string, err error) { - // api.WeixinMiniAPI2.CBRetrieveToken() - result, err := api.WeixinMiniAPI2.GetUnlimited(params.Scene, params.Page) - if err != nil || result == nil { - return retVal, "", err - } - fileName := "wxcode" + utils.Int64ToStr(time.Now().Unix()) + ".jpg" - retVal, err = jxutils.UploadExportContent([]byte(result["fakeData"].(string)), fileName) - // tasks.RefreshWeixinToken() - return retVal, "", err - }) -} - -// @Title 测试websocket -// @Description 测试websocket -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TestWebsocket [get] -func (c *EventController) TestWebsocket() { - // 解决跨域问题(微信小程序) - upgrader.CheckOrigin = func(r *http.Request) bool { - return true - } - //升级将HTTP服务器连接升级到WebSocket协议。 - //responseHeader包含在对客户端升级的响应中 - //请求。使用responseHeader指定Cookie(设置Cookie)和 - //应用程序协商的子目录(Sec WebSocket协议)。 - //如果升级失败,则升级将向客户端答复一个HTTP错误 - ws, err := upgrader.Upgrade(c.Ctx.ResponseWriter, c.Ctx.Request, nil) - if err != nil { - log.Fatal(err) - } - defer ws.Close() - var ( - vendorOrderID = c.GetString("vendorOrderID") - msgMap = make(map[string]*model.ImMessageRecord) - ) - //将当前客户端放入map中 - clients[vendorOrderID] = append(clients[vendorOrderID], ws) - - db := dao.GetDB() - if globals.IsProductEnv() { - _, _, err = jxcontext.New(nil, c.GetString("token"), c.Ctx.ResponseWriter, c.Ctx.Request) - if err != nil { - msg := &CallResult{ - Code: model.ErrCodeGeneralFailed, - Desc: err.Error(), - } - ws.WriteJSON(&msg) - } - } - - c.EnableRender = false //Beego不启用渲染 - - var s *model.ImMessageRecord - for { - //接收客户端的消息 - err := ws.ReadJSON(&s) - if err != nil { - globals.SugarLogger.Debugf("页面可能断开啦 ws.ReadJSON error: %v", err.Error()) - index := 0 - for k, v := range clients[vendorOrderID] { - if v == ws { - index = k - } - } - wsList := clients[vendorOrderID] - clients[vendorOrderID] = clients[vendorOrderID][0:0] - clients[vendorOrderID] = append(clients[vendorOrderID], wsList[0:index]...) - clients[vendorOrderID] = append(clients[vendorOrderID], wsList[index+1:len(wsList)]...) - // delete(clients, ws) //删除map中的客户端 - break //结束循环 - } else { - //接受消息 业务逻辑 - msgMap[vendorOrderID] = s - broadcast <- msgMap - dao.WrapAddIDCULDEntity(s, "") - dao.CreateEntity(db, s) - // fmt.Println("接受到从页面上反馈回来的信息 ", utils.Format4Output(s, false)) - } - } -} - -func init() { - go handleMessages() -} - -//广播推送消息 -func handleMessages() { - for { - //读取通道中的消息 - msg := <-broadcast - globals.SugarLogger.Debugf("clients len %v", len(clients)) - //循环map客户端 - for vendorOrderID, mmsg := range msg { - for _, client := range clients[vendorOrderID] { - //把通道中的消息发送给客户端 - globals.SugarLogger.Debugf("msg %v", utils.Format4Output(mmsg, false)) - err := client.WriteJSON(mmsg) - if err != nil { - globals.SugarLogger.Debugf("client.WriteJSON error: %v", err) - client.Close() //关闭 - index := 0 - for k, v := range clients[vendorOrderID] { - if v == client { - index = k - } - } - wsList := clients[vendorOrderID] - clients[vendorOrderID] = clients[vendorOrderID][0:0] - clients[vendorOrderID] = append(clients[vendorOrderID], wsList[0:index]...) - clients[vendorOrderID] = append(clients[vendorOrderID], wsList[index+1:len(wsList)]...) - // delete(clients, client) //删除map中的客户端 - } - } - } - } -} - -// @Title 查询聊天记录 -// @Description 查询聊天记录 -// @Param token header string true "认证token" -// @Param vendorOrderID query string true "订单号" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetImMessageRecord [get] -func (c *EventController) GetImMessageRecord() { - c.callGetImMessageRecord(func(params *tEventGetImMessageRecordParams) (retVal interface{}, errCode string, err error) { - retVal, err = dao.GetImMessageRecord(dao.GetDB(), params.VendorOrderID, "", 0, -1) - return retVal, "", err - }) -} diff --git a/controllers/financial.go b/controllers/financial.go deleted file mode 100644 index 18b915519..000000000 --- a/controllers/financial.go +++ /dev/null @@ -1,117 +0,0 @@ -package controllers - -import ( - "fmt" - "io" - - "github.com/astaxie/beego" - - "git.rosy.net.cn/jx-callback/business/jxcallback/orderman" - "git.rosy.net.cn/jx-callback/business/jxstore/financial" - "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/model/legacymodel" -) - -type FinancialController struct { - beego.Controller -} - -// @Title 发送文件给门店 -// @Description 发送文件给门店,调用GET方法得到浏览器端参考的上传HTML实现,userfiles -// @Param token header string true "认证token" -// @Param title query string false "消息标题" -// @Param shopName query string false "平台菜市名称" -// @Param isAsync query bool false "是否异步,缺省是同步" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SendFilesToStores [post,get] -func (c *FinancialController) SendFilesToStores() { - if c.Ctx.Input.IsGet() { - w := c.Ctx.ResponseWriter - // 上传页面 - w.Header().Add("Content-Type", "text/html") - w.WriteHeader(200) - html := ` -
- Send this file: - -
-` - io.WriteString(w, html) - } else if c.Ctx.Input.IsPost() { - c.callSendFilesToStores(func(params *tFinancialSendFilesToStoresParams) (retVal interface{}, errCode string, err error) { - r := c.Ctx.Request - files := r.MultipartForm.File["userfiles"] - retVal, err = financial.SendFilesToStores(params.Ctx, files, params.Title, params.ShopName, params.IsAsync, params.Ctx.GetUserName()) - return retVal, "", err - }) - } -} - -// @Title 查询门店账单 -// @Description 查询门店账单 -// @Param token header string true "认证token" -// @Param storeID query int true "门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreBills [get] -func (c *FinancialController) GetStoreBills() { - c.callGetStoreBills(func(params *tFinancialGetStoreBillsParams) (retVal interface{}, errCode string, err error) { - retVal, err = financial.GetStoreBills(params.Ctx, params.StoreID) - return retVal, "", err - }) -} - -// @Param token header string true "认证token" - -// @Title 显示门店最新账单 -// @Description 显示门店最新账单 -// @Param storeID query int true "门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ShowStoreLatestBill [get] -func (c *FinancialController) ShowStoreLatestBill() { - var bills []*legacymodel.StoreBill - w := c.Ctx.ResponseWriter - w.Header().Add("Content-Type", "text/html") - w.WriteHeader(200) - htmlResult := "" - html := ` - %s - ` - c.callShowStoreLatestBill(func(params *tFinancialShowStoreLatestBillParams) (retVal interface{}, errCode string, err error) { - bills, err = financial.GetStoreBills(params.Ctx, params.StoreID) - retVal = bills - if len(bills) == 0 { - err = fmt.Errorf("门店%d没有账单", params.StoreID) - } else { - htmlResult = fmt.Sprintf(html, bills[0].Url) - } - return retVal, model.ErrorCodeIgnore, err - }) - if htmlResult != "" { - io.WriteString(w, htmlResult) - } -} - -// @Title 查询正向订单结账信息 -// @Description 查询正向订单结账信息 -// @Param token header string true "认证token" -// @Param orderID query string false "订单号,如果此项不为空,忽略其它所有查询条件" -// @Param fromDate query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param toDate query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param vendorIDs query string false "订单所属厂商列表[1,2,3],缺省不限制" -// @Param storeIDs query string false "京西门店ID列表[1,2,3],缺省不限制" -// @Param statuss query string false "订单状态列表[1,2,3],缺省不限制" -// @Param cities query string false "城市code列表[1,2,3],缺省不限制" -// @Param offset query int false "结果起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOrdersFinancial [get] -func (c *FinancialController) GetOrdersFinancial() { - c.callGetOrdersFinancial(func(params *tFinancialGetOrdersFinancialParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.FixedOrderManager.GetOrdersFinancial(params.Ctx, params.FromDate, params.ToDate, params.MapData, params.Offset, params.PageSize) - return retVal, "", err - }) -} diff --git a/controllers/init_data.go b/controllers/init_data.go deleted file mode 100644 index b14810151..000000000 --- a/controllers/init_data.go +++ /dev/null @@ -1,53 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/jx-callback/business/jxstore/initdata" - "github.com/astaxie/beego" -) - -type InitDataController struct { - beego.Controller -} - -// @Title 初始化place信息 -// @Description 初始化place信息,要求:jde_city, jde_district, ebde_places, mtpsdeliveryprice -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /InitPlace [post] -func (c *InitDataController) InitPlace() { - c.callInitPlace(func(params *tInitdataInitPlaceParams) (retVal interface{}, errCode string, err error) { - err = initdata.InitPlace(params.Ctx) - return retVal, "", err - }) -} - -// @Title 初始化vendor category -// @Description 初始化vendor category -// @Param token header string true "认证token" -// @Param vendorID formData int true "厂商ID" -// @Param isAsync formData bool false "是否异步操作" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /InitVendorCategory [post] -func (c *InitDataController) InitVendorCategory() { - c.callInitVendorCategory(func(params *tInitdataInitVendorCategoryParams) (retVal interface{}, errCode string, err error) { - retVal, err = initdata.InitVendorCategory(params.Ctx, params.VendorID, params.IsAsync) - return retVal, "", err - }) -} - -// @Title 将资源上传到平台(当前为饿百与美团) -// @Description 将资源上传到平台(当前为饿百与美团) -// @Param token header string true "认证token" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UploadImage4Vendors [post] -func (c *InitDataController) UploadImage4Vendors() { - c.callUploadImage4Vendors(func(params *tInitdataUploadImage4VendorsParams) (retVal interface{}, errCode string, err error) { - retVal, err = initdata.UploadImg4Vendors(params.Ctx, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} diff --git a/controllers/jd2_callback.go b/controllers/jd2_callback.go deleted file mode 100644 index 27a43f5c9..000000000 --- a/controllers/jd2_callback.go +++ /dev/null @@ -1,180 +0,0 @@ -package controllers - -import ( - "net/http" - - "git.rosy.net.cn/baseapi/platformapi/jdapi" - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxcallback/orderman" - "git.rosy.net.cn/jx-callback/business/partner/purchase/jd" - "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego" -) - -// Operations about JDOrder -type Djsw2Controller struct { - beego.Controller -} - -func (c *Djsw2Controller) handleMsg(handler func(*jdapi.API, interface{}) *jdapi.CallbackResponse) (callbackResponse *jdapi.CallbackResponse) { - callbackMsg, _, callbackResponse := jdapi.GetCallbackMsg(getUsefulRequest(c.Ctx)) - globals.SugarLogger.Debug(utils.Format4Output(callbackMsg, true)) - if callbackResponse == nil { - callbackResponse = handler(api.FakeJdAPI, callbackMsg.Param) - } - return callbackResponse -} - -func (c *Djsw2Controller) orderStatus() { - if c.Ctx.Input.Method() == http.MethodPost { - callbackResponse := c.handleMsg(func(a *jdapi.API, obj interface{}) (callbackResponse *jdapi.CallbackResponse) { - if orderMsg, ok := obj.(*jdapi.CallbackOrderMsg); ok { - orderman.FixedOrderManager.OnNewFakeJdOrder(orderMsg.BillID) - } - return nil - }) - c.Data["json"] = c.transferResponse("orderStatus", callbackResponse) - c.ServeJSON() - } else { - c.Abort("404") - } -} - -func (c *Djsw2Controller) NewOrder() { - c.orderStatus() -} - -func (c *Djsw2Controller) OrderAdjust() { - c.nullOperation() -} - -func (c *Djsw2Controller) OrderWaitOutStore() { - c.nullOperation() -} - -func (c *Djsw2Controller) PickFinishOrder() { - c.nullOperation() -} - -func (c *Djsw2Controller) DeliveryOrder() { - c.nullOperation() -} - -func (c *Djsw2Controller) FinishOrder() { - c.nullOperation() -} - -func (c *Djsw2Controller) LockOrder() { - c.nullOperation() -} - -func (c *Djsw2Controller) UnlockOrder() { - c.nullOperation() -} - -func (c *Djsw2Controller) UserCancelOrder() { - c.nullOperation() -} - -func (c *Djsw2Controller) ApplyCancelOrder() { - c.nullOperation() -} - -func (c *Djsw2Controller) VenderAuditApplyCancelOrder() { - c.nullOperation() -} - -func (c *Djsw2Controller) PushDeliveryStatus() { - if c.Ctx.Input.Method() == http.MethodPost { - callbackResponse := c.handleMsg(func(a *jdapi.API, obj interface{}) (callbackResponse *jdapi.CallbackResponse) { - callbackResponse = jd.OnWaybillMsg(obj.(*jdapi.CallbackDeliveryStatusMsg)) - return callbackResponse - }) - c.Data["json"] = c.transferResponse("PushDeliveryStatus", callbackResponse) - c.ServeJSON() - } else { - c.Abort("404") - } -} - -func (c *Djsw2Controller) OrderCommentPush() { - c.nullOperation() -} - -func (c *Djsw2Controller) Token() { - urlValues, err := utils.HTTPBody2Values(c.Ctx.Input.RequestBody, false) - if err == nil { - globals.SugarLogger.Info(utils.Format4Output(utils.URLValues2Map(urlValues), false)) - } - c.Data["json"] = c.transferResponse("Token", nil) - c.ServeJSON() -} - -func (c *Djsw2Controller) StockIsHave() { - c.nullOperation() -} - -func (c *Djsw2Controller) SinglePromoteCreate() { - c.nullOperation() -} - -func (c *Djsw2Controller) StoreCrud() { - c.nullOperation() -} - -func (c *Djsw2Controller) transferResponse(funcName string, inCallbackResponse *jdapi.CallbackResponse) (outCallbackResponse *jdapi.CallbackResponse) { - if globals.IsCallbackAlwaysReturnSuccess() { - return jdapi.SuccessResponse - } - if inCallbackResponse == nil { - return jdapi.SuccessResponse - } - globals.SugarLogger.Debugf("%s callbackResponse:%s", funcName, utils.Format4Output(inCallbackResponse, true)) - return inCallbackResponse -} - -func (c *Djsw2Controller) EndOrderFinance() { - c.nullOperation() -} - -func (c *Djsw2Controller) FinanceAdjustment() { - c.nullOperation() -} - -func (c *Djsw2Controller) DeliveryCarrierModify() { - c.nullOperation() -} - -func (c *Djsw2Controller) NewApplyAfterSaleBill() { - c.nullOperation() -} - -func (c *Djsw2Controller) UpdateApplyAfterSaleBill() { - c.nullOperation() -} - -func (c *Djsw2Controller) NewAfterSaleBill() { - c.nullOperation() -} - -func (c *Djsw2Controller) AfterSaleBillStatus() { - c.nullOperation() -} - -func (c *Djsw2Controller) OrderAccounting() { - c.nullOperation() -} - -func (c *Djsw2Controller) nullOperation() { - c.Data["json"] = c.transferResponse("nullOperation", nil) - c.ServeJSON() -} - -func (c *Djsw2Controller) UpdateSku() { - c.nullOperation() -} - -func (c *Djsw2Controller) OrderAddTips() { - c.nullOperation() -} diff --git a/controllers/jd_callback.go b/controllers/jd_callback.go deleted file mode 100644 index e2d1894ae..000000000 --- a/controllers/jd_callback.go +++ /dev/null @@ -1,234 +0,0 @@ -package controllers - -import ( - "bytes" - "fmt" - "io/ioutil" - "net/http" - - "git.rosy.net.cn/baseapi/platformapi/jdapi" - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/partner/purchase/jd" - "git.rosy.net.cn/jx-callback/globals" - "github.com/astaxie/beego" - "github.com/astaxie/beego/context" -) - -// Operations about JDOrder -type DjswController struct { - beego.Controller -} - -func (c *DjswController) handleMsg(handler func(*jdapi.API, interface{}) *jdapi.CallbackResponse) (callbackResponse *jdapi.CallbackResponse) { - callbackMsg, mapData, callbackResponse := jdapi.GetCallbackMsg(getUsefulRequest(c.Ctx)) - globals.SugarLogger.Debug(utils.Format4Output(callbackMsg, true)) - if callbackResponse == nil { - if jdAPI := jd.GetAPI(jd.AppKey2OrgCode(callbackMsg.AppKey)); jdAPI != nil { - if callbackResponse = jdAPI.CheckCallbackValidation(mapData, callbackMsg.Sign); callbackResponse == nil { - callbackResponse = handler(jdAPI, callbackMsg.Param) - } - } else { - callbackResponse = jdapi.Err2CallbackResponse(fmt.Errorf("没有匹配的appKey,非法请求"), "") - } - } - return callbackResponse -} - -func (c *DjswController) orderStatus() { - if c.Ctx.Input.Method() == http.MethodPost { - callbackResponse := c.handleMsg(func(a *jdapi.API, obj interface{}) (callbackResponse *jdapi.CallbackResponse) { - callbackResponse = jd.OnOrderMsg(obj.(*jdapi.CallbackOrderMsg)) - return callbackResponse - }) - c.Data["json"] = c.transferResponse("orderStatus", callbackResponse) - c.ServeJSON() - } else { - c.Abort("404") - } -} - -func (c *DjswController) NewOrder() { - c.orderStatus() -} - -func (c *DjswController) OrderAdjust() { - c.orderStatus() -} - -func (c *DjswController) OrderWaitOutStore() { - c.orderStatus() -} - -func (c *DjswController) PickFinishOrder() { - c.orderStatus() -} - -func (c *DjswController) DeliveryOrder() { - c.orderStatus() -} - -func (c *DjswController) FinishOrder() { - c.orderStatus() -} - -func (c *DjswController) LockOrder() { - c.orderStatus() -} - -func (c *DjswController) UnlockOrder() { - c.orderStatus() -} - -func (c *DjswController) UserCancelOrder() { - c.orderStatus() -} - -func (c *DjswController) ApplyCancelOrder() { - c.orderStatus() -} - -func (c *DjswController) VenderAuditApplyCancelOrder() { - c.orderStatus() -} - -func (c *DjswController) PushDeliveryStatus() { - if c.Ctx.Input.Method() == http.MethodPost { - callbackResponse := c.handleMsg(func(a *jdapi.API, obj interface{}) (callbackResponse *jdapi.CallbackResponse) { - callbackResponse = jd.OnWaybillMsg(obj.(*jdapi.CallbackDeliveryStatusMsg)) - return callbackResponse - }) - c.Data["json"] = c.transferResponse("PushDeliveryStatus", callbackResponse) - c.ServeJSON() - } else { - c.Abort("404") - } -} - -func (c *DjswController) OrderCommentPush() { - c.orderStatus() -} - -func (c *DjswController) Token() { - urlValues, err := utils.HTTPBody2Values(c.Ctx.Input.RequestBody, false) - if err == nil { - globals.SugarLogger.Info(utils.Format4Output(utils.URLValues2Map(urlValues), false)) - } - c.Data["json"] = c.transferResponse("Token", nil) - c.ServeJSON() -} - -func (c *DjswController) StockIsHave() { - // globals.SugarLogger.Info(string(c.Ctx.Input.RequestBody)) - if c.Ctx.Input.Method() == http.MethodPost { - callbackResponse := c.handleMsg(func(a *jdapi.API, obj interface{}) (callbackResponse *jdapi.CallbackResponse) { - return callbackResponse - }) - c.Data["json"] = c.transferResponse("StockIsHave", callbackResponse) - c.ServeJSON() - } else { - c.Abort("404") - } -} - -func (c *DjswController) SinglePromoteCreate() { - if c.Ctx.Input.Method() == http.MethodPost { - callbackResponse := c.handleMsg(func(a *jdapi.API, obj interface{}) (callbackResponse *jdapi.CallbackResponse) { - callbackResponse = jd.OnActMsg(obj.(*jdapi.CallbackOrderMsg)) - return callbackResponse - }) - c.Data["json"] = c.transferResponse("SinglePromoteCreate", callbackResponse) - c.ServeJSON() - } else { - c.Abort("404") - } -} - -func (c *DjswController) StoreCrud() { - if c.Ctx.Input.Method() == http.MethodPost { - callbackResponse := c.handleMsg(func(a *jdapi.API, obj interface{}) (callbackResponse *jdapi.CallbackResponse) { - callbackResponse = jd.OnStoreMsg(obj.(*jdapi.CallbackOrderMsg)) - return callbackResponse - }) - c.Data["json"] = c.transferResponse("StoreCrud", callbackResponse) - c.ServeJSON() - } else { - c.Abort("404") - } -} - -func (c *DjswController) transferResponse(funcName string, inCallbackResponse *jdapi.CallbackResponse) (outCallbackResponse *jdapi.CallbackResponse) { - if globals.IsCallbackAlwaysReturnSuccess() { - return jdapi.SuccessResponse - } - if inCallbackResponse == nil { - return jdapi.SuccessResponse - } - globals.SugarLogger.Debugf("%s callbackResponse:%s", funcName, utils.Format4Output(inCallbackResponse, true)) - return inCallbackResponse -} - -func (c *DjswController) EndOrderFinance() { - c.nullOperation() -} - -func (c *DjswController) FinanceAdjustment() { - c.nullOperation() -} - -func (c *DjswController) DeliveryCarrierModify() { - c.nullOperation() -} - -func (c *DjswController) NewApplyAfterSaleBill() { - c.orderStatus() -} - -func (c *DjswController) UpdateApplyAfterSaleBill() { - c.orderStatus() -} - -func (c *DjswController) NewAfterSaleBill() { - c.orderStatus() -} - -func (c *DjswController) AfterSaleBillStatus() { - c.orderStatus() -} - -func (c *DjswController) OrderAccounting() { - c.orderStatus() -} - -func getUsefulRequest(ctx *context.Context) *http.Request { - ctx.Request.Body = ioutil.NopCloser(bytes.NewReader(ctx.Input.RequestBody)) - return ctx.Request -} - -func (c *DjswController) nullOperation() { - c.Data["json"] = c.transferResponse("nullOperation", nil) - c.ServeJSON() -} - -func (c *DjswController) UpdateSku() { - c.nullOperation() -} - -func (c *DjswController) OrderAddTips() { - c.orderStatus() -} -func (c *DjswController) OrderInfoChange() { - if c.Ctx.Input.Method() == http.MethodPost { - callbackResponse := c.handleMsg(func(a *jdapi.API, obj interface{}) (callbackResponse *jdapi.CallbackResponse) { - callbackResponse = jd.OnOrderInfoChangeMsg(obj.(*jdapi.CallbackOrderInfoChangeMsg)) - return callbackResponse - }) - c.Data["json"] = c.transferResponse("OrderInfoChange", callbackResponse) - c.ServeJSON() - } else { - c.Abort("404") - } -} - -// func (c *DjswController) OrderInfoChange() { -// c.orderStatus() -// } diff --git a/controllers/jds_callback.go b/controllers/jds_callback.go deleted file mode 100644 index 35bfb65b3..000000000 --- a/controllers/jds_callback.go +++ /dev/null @@ -1,34 +0,0 @@ -package controllers - -import ( - "bytes" - "io/ioutil" - "net/http" - - "git.rosy.net.cn/jx-callback/business/partner/purchase/jdshop" - - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego" -) - -type JdsController struct { - beego.Controller -} - -func (c *JdsController) Msg() { - if c.Ctx.Input.Method() == http.MethodPost { - ctx := c.Ctx - ctx.Request.Body = ioutil.NopCloser(bytes.NewReader(ctx.Input.RequestBody)) - call, err := api.JdShopAPI.GetCallbackMsg(ctx.Request) - if err == nil { - jdshop.OnCallbackMsg(call) - } - globals.SugarLogger.Debugf("jds callback callbackResponse:%s", utils.Format4Output(call, true)) - c.Data["json"] = call - c.ServeJSON() - } else { - c.Abort("404") - } -} diff --git a/controllers/jx_order.go b/controllers/jx_order.go deleted file mode 100644 index 952722fed..000000000 --- a/controllers/jx_order.go +++ /dev/null @@ -1,1203 +0,0 @@ -package controllers - -import ( - "fmt" - "strings" - "time" - - "git.rosy.net.cn/jx-callback/business/partner" - - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxcallback/orderman" - "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch" - "git.rosy.net.cn/jx-callback/business/jxstore/misc" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/jxutils/netprinter" - "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/model/dao" - "git.rosy.net.cn/jx-callback/globals" - "github.com/astaxie/beego" -) - -// 订单相关API -type OrderController struct { - beego.Controller -} - -func (c *OrderController) URLMapping() { - c.Mapping("GetOrderSkuInfo", c.GetOrderSkuInfo) - - c.Mapping("FinishedPickup", c.FinishedPickup) - c.Mapping("SelfDelivering", c.SelfDelivering) - c.Mapping("CreateWaybillOnProviders", c.CreateWaybillOnProviders) - c.Mapping("SelfDelivered", c.SelfDelivered) -} - -// @Title 完成拣货 -// @Description 完成拣货 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属的厂商ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /FinishedPickup [post] -func (c *OrderController) FinishedPickup() { - c.callFinishedPickup(func(params *tOrderFinishedPickupParams) (retVal interface{}, errCode string, err error) { - err = defsch.FixedScheduler.PickupGoodsAndUpdateStatus(params.Ctx, params.VendorOrderID, params.VendorID, params.Ctx.GetUserName()) - return nil, "", err - }) -} - -// @Title 转自送 -// @Description 转自送,对于配送类型为纯自送的,就是表示自送开始 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属的厂商ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SelfDelivering [post] -func (c *OrderController) SelfDelivering() { - c.callSelfDelivering(func(params *tOrderSelfDeliveringParams) (retVal interface{}, errCode string, err error) { - err = defsch.FixedScheduler.SelfDeliveringAndUpdateStatus(params.Ctx, params.VendorOrderID, params.VendorID, params.Ctx.GetUserName()) - return nil, "", err - }) -} - -// @Title 自送送达 -// @Description 自送送达 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属的厂商ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SelfDelivered [post] -func (c *OrderController) SelfDelivered() { - c.callSelfDelivered(func(params *tOrderSelfDeliveredParams) (retVal interface{}, errCode string, err error) { - err = defsch.FixedScheduler.SelfDeliveredAndUpdateStatus(params.Ctx, params.VendorOrderID, params.VendorID, params.Ctx.GetUserName()) - return nil, "", err - }) -} - -// @Title 自送送达 -// @Description 自送送达 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属的厂商ID" -// @Param selfTakeCode formData string true "自提码" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ConfirmSelfTake [post] -func (c *OrderController) ConfirmSelfTake() { - c.callConfirmSelfTake(func(params *tOrderConfirmSelfTakeParams) (retVal interface{}, errCode string, err error) { - err = defsch.FixedScheduler.ConfirmSelfTake(params.Ctx, params.VendorOrderID, params.VendorID, params.SelfTakeCode) - return retVal, "", err - }) -} - -// @Title 查询三方运单费用信息 -// @Description 查询三方运单费用信息 -// @Param token header string true "认证token" -// @Param vendorOrderID query string true "订单ID" -// @Param vendorID query int true "订单所属的厂商ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /QueryOrderWaybillFeeInfo [get] -func (c *OrderController) QueryOrderWaybillFeeInfo() { - c.callQueryOrderWaybillFeeInfo(func(params *tOrderQueryOrderWaybillFeeInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = defsch.FixedScheduler.QueryOrderWaybillFeeInfoEx(params.Ctx, params.VendorOrderID, params.VendorID) - return retVal, "", err - }) -} - -// @Title 创建三方运单 -// @Description 创建三方运单 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属的厂商ID" -// @Param courierVendorIDs formData string false "运单厂商ID(缺省全部)" -// @Param maxDeliveryFee formData int false "最高限价(为0时为缺省最大值)" -// @Param forceCreate formData bool false "是否强制创建(忽略订单状态检查及其它参数)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateWaybillOnProviders [post] -func (c *OrderController) CreateWaybillOnProviders() { - c.callCreateWaybillOnProviders(func(params *tOrderCreateWaybillOnProvidersParams) (retVal interface{}, errCode string, err error) { - var courierVendorIDs []int - if err = jxutils.Strings2Objs(params.CourierVendorIDs, &courierVendorIDs); err == nil { - retVal, err = defsch.FixedScheduler.CreateWaybillOnProvidersEx(params.Ctx, params.VendorOrderID, params.VendorID, courierVendorIDs, params.ForceCreate, int64(params.MaxDeliveryFee)) - } - return retVal, "", err - }) -} - -// @Title 取消所有三方运单 -// @Description 取消所有三方运单 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属的厂商ID" -// @Param isStopSchedule formData bool false "是否停止运单调度" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CancelAll3rdWaybills [post] -func (c *OrderController) CancelAll3rdWaybills() { - c.callCancelAll3rdWaybills(func(params *tOrderCancelAll3rdWaybillsParams) (retVal interface{}, errCode string, err error) { - err = defsch.FixedScheduler.CancelAll3rdWaybills(params.Ctx, params.VendorOrderID, params.VendorID, params.IsStopSchedule) - return retVal, "", err - }) -} - -// @Title 取消三方运单 -// @Description 取消三方运单 -// @Param token header string true "认证token" -// @Param vendorWaybillID formData string true "运单ID" -// @Param waybillVendorID formData int true "运单所属的厂商ID" -// @Param reasonID formData int false "原因ID" -// @Param reason formData string false "取消原因" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CancelWaybill [post] -func (c *OrderController) CancelWaybill() { - c.callCancelWaybill(func(params *tOrderCancelWaybillParams) (retVal interface{}, errCode string, err error) { - reasonID := params.ReasonID - if reasonID == 0 { - reasonID = partner.CancelWaybillReasonOther - } - err = defsch.FixedScheduler.CancelWaybillByID(params.Ctx, params.VendorWaybillID, params.WaybillVendorID, reasonID, params.Reason) - return retVal, "", err - }) -} - -// @Title 得到门店订单信息 -// @Description 得到门店订单信息 -// @Param token header string true "认证token" -// @Param storeID query int true "京西门店ID" -// @Param lastHours query int false "最近多少小时的信息(缺省为两天)" -// @Param lastMinutes query int false "最近多少分钟的信息(缺省为不传)" -// @Param isIncludeFake query bool false "是否包括假订单" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreOrderCountInfo [get] -func (c *OrderController) GetStoreOrderCountInfo() { - c.callGetStoreOrderCountInfo(func(params *tOrderGetStoreOrderCountInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.FixedOrderManager.GetStoreOrderCountInfo(params.Ctx, params.StoreID, params.LastHours, params.LastMinutes, params.IsIncludeFake) - return retVal, "", err - }) -} - -// @Title 得到订单SKU信息 -// @Description 得到订单SKU信息 -// @Param token header string true "认证token" -// @Param vendorOrderID query string true "订单ID" -// @Param vendorID query int true "订单所属的厂商ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOrderSkuInfo [get] -func (c *OrderController) GetOrderSkuInfo() { - c.callGetOrderSkuInfo(func(params *tOrderGetOrderSkuInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.FixedOrderManager.GetOrderSkuInfo(params.Ctx, params.VendorOrderID, params.VendorID) - return retVal, "", err - }) -} - -// @Title 得到订单详情 -// @Description 得到订单详情 -// @Param token header string true "认证token" -// @Param vendorOrderID query string true "订单ID" -// @Param vendorID query int true "订单所属的厂商ID" -// @Param refresh query bool false "是否从购物平台刷新数据" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOrderInfo [get] -func (c *OrderController) GetOrderInfo() { - c.callGetOrderInfo(func(params *tOrderGetOrderInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.FixedOrderManager.GetOrderInfo(params.Ctx, params.VendorOrderID, params.VendorID, params.Refresh) - return retVal, "", err - }) -} - -// @Title 得到订单运单信息 -// @Description 得到订单运单信息 -// @Param token header string true "认证token" -// @Param vendorOrderID query string true "订单ID" -// @Param vendorID query int true "订单所属的厂商ID" -// @Param isNotEnded query bool false "是否只是没有结束的运单" -// @Param isGetPos query bool false "是否得到骑手位置" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOrderWaybillInfo [get] -func (c *OrderController) GetOrderWaybillInfo() { - c.callGetOrderWaybillInfo(func(params *tOrderGetOrderWaybillInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.FixedOrderManager.GetOrderWaybillInfo(params.Ctx, params.VendorOrderID, params.VendorID, params.IsNotEnded, params.IsGetPos) - return retVal, "", err - }) -} - -// @Title 补全遗漏的订单 -// @Description 补全遗漏的订单 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属的厂商ID" -// @Param tipFee formData int true "小费" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateOrderWaybillTip [post] -func (c *OrderController) UpdateOrderWaybillTip() { - c.callUpdateOrderWaybillTip(func(params *tOrderUpdateOrderWaybillTipParams) (retVal interface{}, errCode string, err error) { - err = defsch.FixedScheduler.SetOrderWaybillTip(params.Ctx, params.VendorOrderID, params.VendorID, int64(params.TipFee)) - return retVal, "", err - }) -} - -// @Title 导出美团运单 -// @Description 导出美团运单(excel文件),注意时间跨度不要太长,最多只能是一个月 -// @Param token header string true "认证token" -// @Param fromDate query string true "开始日期(包含),格式(2006-01-02)" -// @Param toDate query string false "结束日期(包含),格式(2006-01-02)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ExportMTWaybills [get] -func (c *OrderController) ExportMTWaybills() { - var content []byte - var fromDate, toDate string - c.callExportMTWaybills(func(params *tOrderExportMTWaybillsParams) (retVal interface{}, errCode string, err error) { - fromDate = params.FromDate - toDate = params.ToDate - if toDate == "" { - toDate = fromDate - } - content, err = orderman.FixedOrderManager.ExportMTWaybills(params.Ctx, params.FromDate, params.ToDate) - globals.SugarLogger.Debug(err) - return retVal, model.ErrorCodeIgnore, err - }) - if content != nil { - c.Ctx.ResponseWriter.Header().Set("Content-Type", "application/vnd.ms-excel") - fileName := strings.Replace(fmt.Sprintf("attachment;filename=美团运单表%s至%sat%s.xlsx", fromDate, toDate, utils.Time2Str(time.Now())), " ", "-", 1) - c.Ctx.ResponseWriter.Header().Set("content-disposition", fileName) - c.Ctx.ResponseWriter.Write(content) - } -} - -// @Title 查询订单 -// @Description 查询订单 -// @Param token header string true "认证token" -// @Param orderID query string false "订单号,如果此项不为空,忽略其它所有查询条件(此项会废弃,用vendorOderID)" -// @Param vendorOrderID query string false "订单号,如果此项不为空,忽略其它所有查询条件" -// @Param keyword query string false "查询关键字" -// @Param fromDate query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param toDate query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param isDateFinish query bool false "是否fromDate与toDate指的是订单结束日期,缺省不是" -// @Param vendorIDs query string false "订单所属厂商列表[1,2,3],缺省不限制" -// @Param waybillVendorIDs query string false "承运人所属厂商列表[1,2,3],缺省不限制" -// @Param storeIDs query string false "京西门店ID列表[1,2,3],缺省不限制" -// @Param statuss query string false "订单状态列表[1,2,3],缺省不限制" -// @Param lockStatuss query string false "订单锁定状态列表[1,2,3],缺省不限制" -// @Param cities query string false "城市code列表[1,2,3],缺省不限制" -// @Param isIncludeFake query bool false "是否包括假订单" -// @Param skuIDs query string false "包含的skuID列表,或的关系" -// @Param isJxFirst query bool false "排序是否京西订单优先(缺省为否)" -// @Param adjustCount query int false "最小调整次数" -// @Param mustInvoice query bool false "是否必须要求开发票" -// @Param offset query int false "结果起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOrders [get,post] -func (c *OrderController) GetOrders() { - c.callGetOrders(func(params *tOrderGetOrdersParams) (retVal interface{}, errCode string, err error) { - var skuIDs []int - if err = jxutils.Strings2Objs(params.SkuIDs, &skuIDs); err == nil { - retVal, err = orderman.FixedOrderManager.GetOrders(params.Ctx, params.IsIncludeFake, params.FromDate, params.ToDate, params.IsDateFinish, skuIDs, params.IsJxFirst, params.MapData, params.Offset, params.PageSize) - } - return retVal, "", err - }) -} - -// @Title 导出订单(包括SKU信息) -// @Description 导出订单(包括SKU信息) -// @Param token header string true "认证token" -// @Param orderID query string false "订单号,如果此项不为空,忽略其它所有查询条件(此项会废弃,用vendorOderID)" -// @Param vendorOrderID query string false "订单号,如果此项不为空,忽略其它所有查询条件" -// @Param keyword query string false "查询关键字" -// @Param fromDate query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param toDate query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param vendorIDs query string false "订单所属厂商列表[1,2,3],缺省不限制" -// @Param waybillVendorIDs query string false "承运人所属厂商列表[1,2,3],缺省不限制" -// @Param storeIDs query string false "京西门店ID列表[1,2,3],缺省不限制" -// @Param statuss query string false "订单状态列表[1,2,3],缺省不限制" -// @Param lockStatuss query string false "订单锁定状态列表[1,2,3],缺省不限制" -// @Param cities query string false "城市code列表[1,2,3],缺省不限制" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ExportOrders [get] -func (c *OrderController) ExportOrders() { - c.callExportOrders(func(params *tOrderExportOrdersParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.FixedOrderManager.ExportOrders(params.Ctx, params.FromDate, params.ToDate, params.MapData) - return retVal, "", err - }) -} - -// @Title 查询售后单 -// @Description 查询售后单 -// @Param token header string true "认证token" -// @Param afsOrderID query string false "售后单号,如果此项不为空,忽略其它所有查询条件" -// @Param vendorOrderID query string false "订单号,如果此项不为空,忽略其它所有查询条件" -// @Param vendorIDs query string false "订单所属厂商列表[1,2,3],缺省不限制" -// @Param appealTypes query string false "售后处理s方式列表" -// @Param storeIDs query string false "京西门店ID列表[1,2,3],缺省不限制" -// @Param statuss query string false "订单状态列表[1,2,3],缺省不限制" -// @Param keyword query string false "查询关键字" -// @Param fromTime query string false "开始时间,如果订单号为空此项必须要求" -// @Param toTime query string false "结束时间,如果订单号为空此项必须要求" -// @Param skuIDs query string false "包含的skuID列表,或的关系" -// @Param offset query int false "结果起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetAfsOrders [get,post] -func (c *OrderController) GetAfsOrders() { - c.callGetAfsOrders(func(params *tOrderGetAfsOrdersParams) (retVal interface{}, errCode string, err error) { - timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime) - if err == nil { - var vendorIDList, appealTypeList, storeIDList, statusList, skuIDs []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.AppealTypes, &appealTypeList, - params.StoreIDs, &storeIDList, params.Statuss, &statusList, params.SkuIDs, &skuIDs); err == nil { - retVal, err = orderman.FixedOrderManager.GetAfsOrders(params.Ctx, params.Keyword, params.AfsOrderID, - params.VendorOrderID, vendorIDList, appealTypeList, storeIDList, statusList, skuIDs, timeList[0], timeList[1], - params.Offset, params.PageSize) - } - } - return retVal, "", err - }) -} - -// @Title 得到售后单SKU信息 -// @Description 得到售后单SKU信息(订单与售后单必填一项) -// @Param token header string true "认证token" -// @Param vendorID query int true "售后单所属的厂商ID" -// @Param vendorOrderID query string false "订单ID" -// @Param afsOrderID query string false "售后单ID" -// @Param isNotFaild query bool false "是否查非失败的" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetAfsOrderSkuInfo [get] -func (c *OrderController) GetAfsOrderSkuInfo() { - c.callGetAfsOrderSkuInfo(func(params *tOrderGetAfsOrderSkuInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = dao.GetAfsOrderSkuInfo(dao.GetDB(), params.VendorOrderID, params.AfsOrderID, params.VendorID, params.IsNotFaild) - return retVal, "", err - }) -} - -// @Title 查询运单 -// @Description 查询运单 -// @Param token header string true "认证token" -// @Param keyword query string false "查询关键字" -// @Param fromDate query string true "开始日期(包含),格式(2006-01-02)" -// @Param toDate query string false "结束日期(包含),格式(2006-01-02)" -// @Param waybillVendorIDs query string false "承运人所属厂商列表[1,2,3],缺省不限制" -// @Param statuss query string false "运单状态列表[1,2,3],缺省不限制" -// @Param offset query int false "结果起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetWaybills [get] -func (c *OrderController) GetWaybills() { - c.callGetWaybills(func(params *tOrderGetWaybillsParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.FixedOrderManager.GetWaybills(params.Ctx, params.FromDate, params.ToDate, params.MapData, params.Offset, params.PageSize) - return retVal, "", err - }) -} - -// @Title 查询订单/运单事件 -// @Description 查询订单/运单事件 -// @Param token header string true "认证token" -// @Param vendorOrderID query string true "订单/运单ID" -// @Param vendorID query int true "订单/运单所属厂商ID)" -// @Param orderType query int true "订单:1;运单:2;订单+运单:-1" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOrderStatusList [get] -func (c *OrderController) GetOrderStatusList() { - c.callGetOrderStatusList(func(params *tOrderGetOrderStatusListParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.FixedOrderManager.GetOrderStatusList(params.Ctx, params.VendorOrderID, params.VendorID, params.OrderType) - return retVal, "", err - }) -} - -// @Title 查询门店营业数据 -// @Description 查询门店营业数据 -// @Param token header string true "认证token" -// @Param storeIDs query string false "京西门店ID列表[1,2,3],缺省不限制" -// @Param fromTime query string true "起始时间" -// @Param toTime query string true "结束时间" -// @Param statuss query string false "订单状态列表[1,2,3],缺省不限制" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoresOrderSaleInfo [get] -func (c *OrderController) GetStoresOrderSaleInfo() { - c.callGetStoresOrderSaleInfo(func(params *tOrderGetStoresOrderSaleInfoParams) (retVal interface{}, errCode string, err error) { - timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime) - if err == nil { - var storeIDList []int - var statusList []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList, params.Statuss, &statusList); err == nil { - retVal, err = orderman.FixedOrderManager.GetStoresOrderSaleInfo(params.Ctx, storeIDList, timeList[0], timeList[1], statusList) - } - } - return retVal, "", err - }) -} - -// @Title 刷新订单真实手机号 -// @Description 刷新订单真实手机号 -// @Param token header string true "认证token" -// @Param vendorID formData int true "厂商ID" -// @Param fromTime formData string true "起始时间" -// @Param toTime formData string false "结束时间" -// @Param isAsync formData bool true "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshOrderRealMobile [put] -func (c *OrderController) RefreshOrderRealMobile() { - c.callRefreshOrderRealMobile(func(params *tOrderRefreshOrderRealMobileParams) (retVal interface{}, errCode string, err error) { - timeList, err2 := jxutils.BatchStr2Time(params.FromTime, params.ToTime) - if err = err2; err == nil { - retVal, err = misc.RefreshRealMobile(params.Ctx, params.VendorID, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 刷新订单平台结算信息 -// @Description 刷新订单平台结算信息 -// @Param token header string true "认证token" -// @Param fromTime formData string true "起始时间" -// @Param toTime formData string false "结束时间" -// @Param isAsync formData bool true "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshOrderFinancial [put] -func (c *OrderController) RefreshOrderFinancial() { - c.callRefreshOrderFinancial(func(params *tOrderRefreshOrderFinancialParams) (retVal interface{}, errCode string, err error) { - timeList, err2 := jxutils.BatchStr2Time(params.FromTime, params.ToTime) - if err = err2; err == nil { - retVal, err = orderman.FixedOrderManager.RefreshOrderFinancial(params.Ctx, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 设置订单打印状态 -// @Description 同步商家SKU类别 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单/运单ID" -// @Param vendorID formData int true "订单/运单所属厂商ID)" -// @Param isPrinted formData bool true "是否打印" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SetOrderPrintStatus [put] -func (c *OrderController) SetOrderPrintStatus() { - c.callSetOrderPrintStatus(func(params *tOrderSetOrderPrintStatusParams) (retVal interface{}, errCode string, err error) { - err = dao.SetOrderPrintFlag(dao.GetDB(), params.Ctx.GetUserName(), params.VendorOrderID, params.VendorID, params.IsPrinted) - return retVal, "", err - }) -} - -// @Title 网络打印订单 -// @Description 网络打印订单 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单/运单ID" -// @Param vendorID formData int true "订单/运单所属厂商ID)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /PrintOrder [put] -func (c *OrderController) PrintOrder() { - c.callPrintOrder(func(params *tOrderPrintOrderParams) (retVal interface{}, errCode string, err error) { - retVal, err = netprinter.PrintOrder(params.Ctx, params.VendorOrderID, params.VendorID) - return retVal, "", err - }) -} - -// @Title 查询网络打印机状态 -// @Description 查询网络打印机状态 -// @Param token header string true "认证token" -// @Param storeID query int true "门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetPrinterStatus [get] -func (c *OrderController) GetPrinterStatus() { - c.callGetPrinterStatus(func(params *tOrderGetPrinterStatusParams) (retVal interface{}, errCode string, err error) { - retVal, err = netprinter.GetNetPrinterStatus(params.Ctx, params.StoreID) - return retVal, "", err - }) -} - -func skuList2Map(skuList []*model.OrderSku) (skuCount int, skuMap map[int64]*model.OrderSku, outSkuList []*model.OrderSku) { - skuMap = make(map[int64]*model.OrderSku) - for _, sku := range skuList { - skuCount += sku.Count - skuID := jxutils.GetSkuIDFromOrderSku(sku) - if sku.SkuID > 0 { - index := jxutils.Combine2Int(skuID, sku.StoreSubID) - if skuMap[index] == nil { - tmpSku := *sku - skuMap[index] = &tmpSku - outSkuList = append(outSkuList, skuMap[index]) - } else { - skuMap[index].Count += sku.Count - } - } - } - return skuCount, skuMap, outSkuList -} - -func getSkuFromMap(skuMap map[int64]*model.OrderSku, skuID, actID int) (sku *model.OrderSku) { - if sku = skuMap[jxutils.Combine2Int(skuID, actID)]; sku == nil && actID != 0 { - sku = skuMap[jxutils.Combine2Int(skuID, 0)] - } - return sku -} - -// @Title 调整订单 -// @Description 调整订单 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属厂商ID" -// @Param removedSkuInfo formData string true "要去除的商品信息,只有skuID与Count字段有效" -// @Param reason formData string true "调整原因" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AdjustOrder [put] -func (c *OrderController) AdjustOrder() { - c.callAdjustOrder(func(params *tOrderAdjustOrderParams) (retVal interface{}, errCode string, err error) { - var skuList []*model.OrderSku - err = jxutils.Strings2Objs(params.RemovedSkuInfo, &skuList) - if err == nil { - _, _, skuList = skuList2Map(skuList) - var order *model.GoodsOrder - order, err = partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) - if err == nil { - removedAll, err2 := fillSkuList(skuList, order.Skus) - if err = err2; err == nil { - if removedAll { - err = fmt.Errorf("至少要保留一个商品") - } else { - err = defsch.FixedScheduler.AdjustOrder(params.Ctx, order, skuList, params.Reason) - } - } - } - } - return retVal, "", err - }) -} - -// @Title 取消订单 -// @Description 取消订单 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属厂商ID" -// @Param reason formData string false "取消原因" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CancelOrder [put] -func (c *OrderController) CancelOrder() { - c.callCancelOrder(func(params *tOrderCancelOrderParams) (retVal interface{}, errCode string, err error) { - order, err := partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) - if err == nil { - err = defsch.FixedScheduler.CancelOrder(params.Ctx, order, params.Reason) - } - return retVal, "", err - }) -} - -// @Title 审核取货失败 -// @Description 审核取货失败 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属厂商ID" -// @Param acceptIt formData bool true "是否批准" -// @Param reason formData string false "原因" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AcceptOrRefuseFailedGetOrder [put] -func (c *OrderController) AcceptOrRefuseFailedGetOrder() { - c.callAcceptOrRefuseFailedGetOrder(func(params *tOrderAcceptOrRefuseFailedGetOrderParams) (retVal interface{}, errCode string, err error) { - order, err := partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) - if err == nil { - err = defsch.FixedScheduler.AcceptOrRefuseFailedGetOrder(params.Ctx, order, params.AcceptIt, params.Reason) - } - return retVal, "", err - }) -} - -// @Title 取货失败后再次招唤平台配送 -// @Description 取货失败后再次招唤平台配送 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属厂商ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CallPMCourier [put] -func (c *OrderController) CallPMCourier() { - c.callCallPMCourier(func(params *tOrderCallPMCourierParams) (retVal interface{}, errCode string, err error) { - order, err := partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) - if err == nil { - err = defsch.FixedScheduler.CallPMCourier(params.Ctx, order) - } - return retVal, "", err - }) -} - -// @Title 投递失败后确认收到退货 -// @Description 投递失败后确认收到退货 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属厂商ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ConfirmReceiveGoods [put] -func (c *OrderController) ConfirmReceiveGoods() { - c.callConfirmReceiveGoods(func(params *tOrderConfirmReceiveGoodsParams) (retVal interface{}, errCode string, err error) { - order, err := partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) - if err == nil { - err = defsch.FixedScheduler.ConfirmReceiveGoods(params.Ctx, order) - } - return retVal, "", err - }) -} - -// @Title 同意或拒绝用户取消订单申请 -// @Description 同意或拒绝用户取消订单申请 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属厂商ID" -// @Param acceptIt formData bool true "是否批准" -// @Param reason formData string false "原因" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AgreeOrRefuseCancel [put] -func (c *OrderController) AgreeOrRefuseCancel() { - c.callAgreeOrRefuseCancel(func(params *tOrderAgreeOrRefuseCancelParams) (retVal interface{}, errCode string, err error) { - order, err := partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) - if err == nil { - if err = defsch.FixedScheduler.AgreeOrRefuseCancel(params.Ctx, order, params.AcceptIt, params.Reason); err == nil /*&& params.AcceptIt*/ { - order.LockStatus = model.OrderStatusUnknown - err = partner.CurOrderManager.UpdateOrderFields(order, []string{"LockStatus"}) - } - } - return retVal, "", err - }) -} - -// @Title 审核售后单申请 -// @Description 审核售后单申请 -// @Param token header string true "认证token" -// @Param afsOrderID formData string true "售后ID" -// @Param vendorID formData int true "订单所属厂商ID" -// @Param approveType formData int true "操作类型" -// @Param reason formData string false "原因" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AgreeOrRefuseRefund [put] -func (c *OrderController) AgreeOrRefuseRefund() { - c.callAgreeOrRefuseRefund(func(params *tOrderAgreeOrRefuseRefundParams) (retVal interface{}, errCode string, err error) { - err = defsch.FixedScheduler.AgreeOrRefuseRefund(params.Ctx, params.AfsOrderID, params.VendorID, params.ApproveType, params.Reason) - return retVal, "", err - }) -} - -// @Title 确认收到售后退货 -// @Description 确认收到售后退货 -// @Param token header string true "认证token" -// @Param afsOrderID formData string true "售后ID" -// @Param vendorID formData int true "订单所属厂商ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ConfirmReceivedReturnGoods [put] -func (c *OrderController) ConfirmReceivedReturnGoods() { - c.callConfirmReceivedReturnGoods(func(params *tOrderConfirmReceivedReturnGoodsParams) (retVal interface{}, errCode string, err error) { - err = defsch.FixedScheduler.ConfirmReceivedReturnGoods(params.Ctx, params.AfsOrderID, params.VendorID) - return retVal, "", err - }) -} - -// @Title 得到门店售后单信息 -// @Description 得到门店售后单信息 -// @Param token header string true "认证token" -// @Param storeID query int true "京西门店ID" -// @Param lastHours query int false "最近多少小时的信息(缺省为两天)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStoreAfsOrderCountInfo [get] -func (c *OrderController) GetStoreAfsOrderCountInfo() { - c.callGetStoreAfsOrderCountInfo(func(params *tOrderGetStoreAfsOrderCountInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.FixedOrderManager.GetStoreAfsOrderCountInfo(params.Ctx, params.StoreID, params.LastHours) - return retVal, "", err - }) -} - -// @Title 补全遗漏的订单 -// @Description 补全遗漏的订单 -// @Param token header string true "认证token" -// @Param fromDate formData string true "订单起始日期" -// @Param toDate formData string false "订单结束日期" -// @Param vendorIDs formData string false "订单所属的厂商ID列表" -// @Param storeID formData int false "门店ID" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个失败是否继续,缺省true" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AmendMissingOrders [post] -func (c *OrderController) AmendMissingOrders() { - c.callAmendMissingOrders(func(params *tOrderAmendMissingOrdersParams) (retVal interface{}, errCode string, err error) { - timeList, err := jxutils.BatchStr2Time(params.FromDate, params.ToDate) - if err == nil { - var vendorIDs []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs); err == nil { - retVal, err = orderman.FixedOrderManager.AmendMissingOrders(params.Ctx, vendorIDs, params.StoreID, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError) - } - } - return retVal, "", err - }) -} - -// @Title 同步刷新历史订单的结算价按订单 -// @Description 同步刷新历史订单的结算价按订单 -// @Param token header string true "认证token" -// @Param fromTime formData string false "订单起始时间 (yyyy-mm-dd hh:ms:ss)" -// @Param toTime formData string false "订单结束时间 (yyyy-mm-dd hh:ms:ss)" -// @Param vendorOrderID formData string false "订单号" -// @Param vendorIDs formData string false "平台ID列表[0,1,3]" -// @Param actID formData int false "活动ID" -// @Param storeID formData int false "门店ID" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个失败是否继续,缺省true" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshHistoryOrdersEarningPrice [post] -func (c *OrderController) RefreshHistoryOrdersEarningPrice() { - c.callRefreshHistoryOrdersEarningPrice(func(params *tOrderRefreshHistoryOrdersEarningPriceParams) (retVal interface{}, errCode string, err error) { - var vendorIDList []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList); err == nil { - retVal, errCode, err = orderman.FixedOrderManager.RefreshHistoryOrdersEarningPrice(params.Ctx, params.VendorOrderID, params.ActID, vendorIDList, params.StoreID, params.FromTime, params.ToTime, params.IsAsync, params.IsContinueWhenError) - } - return retVal, errCode, err - }) -} - -// @Title 商家主动发起部分退款售后 -// @Description 商家主动发起部分退款售后 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属厂商ID" -// @Param refundSkuList formData string true "要去除的商品信息,只有skuID与Count字段有效" -// @Param reason formData string true "原因" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /PartRefundOrder [put] -func (c *OrderController) PartRefundOrder() { - c.callPartRefundOrder(func(params *tOrderPartRefundOrderParams) (retVal interface{}, errCode string, err error) { - var skuList []*model.OrderSku - err = jxutils.Strings2Objs(params.RefundSkuList, &skuList) - if err == nil { - _, _, skuList = skuList2Map(skuList) - var order *model.GoodsOrder - order, err = partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) - if err == nil { - removedAll, err2 := fillSkuList(skuList, order.Skus) - if err = err2; err == nil { - if removedAll { - err = defsch.FixedScheduler.RefundOrder(params.Ctx, order, params.Reason) - } else { - err = defsch.FixedScheduler.PartRefundOrder(params.Ctx, order, skuList, params.Reason) - } - } - } - } - return retVal, "", err - }) -} - -func fillSkuList(skuList, orderSkuList []*model.OrderSku) (isSame bool, err error) { - skuCount, orderSkuMap, _ := skuList2Map(orderSkuList) - skuCount2 := 0 - for _, sku := range skuList { - skuCount2 += sku.Count - skuID := jxutils.GetSkuIDFromOrderSku(sku) - actID := sku.StoreSubID - sku2 := getSkuFromMap(orderSkuMap, skuID, actID) - if sku2 == nil { - err = fmt.Errorf("找不到SKU:%d", skuID) - } else if sku.Count > sku2.Count { - err = fmt.Errorf("SKU:%d调整数量:%d大于实际数量:%d", skuID, sku.Count, sku2.Count) - } - if err != nil { - break - } else { - count := sku.Count - *sku = *sku2 - sku.Count = count - } - } - return skuCount == skuCount2, err -} - -// @Title 商家主动发起全额退款售后 -// @Description 商家主动发起全额退款售后 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属厂商ID" -// @Param reason formData string false "退款原因" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefundOrder [put] -func (c *OrderController) RefundOrder() { - c.callRefundOrder(func(params *tOrderRefundOrderParams) (retVal interface{}, errCode string, err error) { - order, err := orderman.FixedOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) - if err != nil { - return nil, "", err - } - afsSkuList, err := dao.GetAfsOrderSkuInfo(dao.GetDB(), params.VendorOrderID, "", params.VendorID, false) - if err != nil { - return nil, "", err - } - order = jxutils.RemoveSkuFromOrder(order, afsSkus2OrderSkus(afsSkuList)) - err = defsch.FixedScheduler.RefundOrder(params.Ctx, order, params.Reason) - return retVal, "", err - }) -} - -func afsSkus2OrderSkus(afsSkuList []*model.OrderFinancialSkuExt) (skuList []*model.OrderSku) { - for _, v := range afsSkuList { - if v.IsAfsOrder == 1 { - skuList = append(skuList, &model.OrderSku{ - SkuID: v.SkuID, - VendorSkuID: v.VendorSkuID, - Count: v.Count, - }) - } - } - return skuList -} - -// @Title 订单门店归属补漏 -// @Description 订单门店归属补漏 -// @Param token header string true "认证token" -// @Param fromDate formData string false "开始日期" -// @Param toDate formData string false "结束日期(缺省不限制)" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshOrdersWithoutJxStoreID [post] -func (c *OrderController) RefreshOrdersWithoutJxStoreID() { - c.callRefreshOrdersWithoutJxStoreID(func(params *tOrderRefreshOrdersWithoutJxStoreIDParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.RefreshOrdersWithoutJxStoreID(params.Ctx, params.FromDate, params.ToDate, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 获取投诉原因 -// @Description 获取投诉原因 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetComplaintReasons [get] -func (c *OrderController) GetComplaintReasons() { - c.callGetComplaintReasons(func(params *tOrderGetComplaintReasonsParams) (retVal interface{}, errCode string, err error) { - retVal = orderman.GetComplaintReasons() - return retVal, "", err - }) -} - -// @Title 投诉骑手(三方运送) -// @Description 投诉骑手(三方运送) -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属厂商ID" -// @Param waybillVendorID formData int true "运单所属厂商ID" -// @Param complaintID formData int true "投诉原因ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ComplaintRider [post] -func (c *OrderController) ComplaintRider() { - c.callComplaintRider(func(params *tOrderComplaintRiderParams) (retVal interface{}, errCode string, err error) { - err = orderman.ComplaintRider(params.Ctx, params.VendorOrderID, params.VendorID, params.WaybillVendorID, params.ComplaintID) - return retVal, "", err - }) -} - -// @Title 查询门店订单扣款记录 -// @Description 查询门店订单扣款记录 -// @Param token header string true "认证token" -// @Param storeIDs query string false "门店ID列表" -// @Param vendorOrderID query string false "订单ID" -// @Param vendorIDs query string false "订单所属厂商ID列表" -// @Param fromTime query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param toTime query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param statuss query string false "账单状态列表,0是未结账,1是已结账,-1为作废" -// @Param type query int false "扣款类型,1为差评补贴,2为优惠券" -// @Param isReverse query int false "只查冲账记录,0为默认都查,1为只查冲账,-1为不查冲账" -// @Param offset query int false "结果起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOrdersSupplement [get] -func (c *OrderController) GetOrdersSupplement() { - var vendorIDList, storeIDList, statusList []int - c.callGetOrdersSupplement(func(params *tOrderGetOrdersSupplementParams) (retVal interface{}, errCode string, err error) { - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList, params.Statuss, &statusList); err == nil { - retVal, err = orderman.GetOrdersSupplement(params.Ctx, storeIDList, vendorIDList, statusList, params.VendorOrderID, params.FromTime, params.ToTime, params.Type, params.IsReverse, params.Offset, params.PageSize) - } - return retVal, "", err - }) -} - -// @Title 新增修改扣款记录 -// @Description 新增修改扣款记录 -// @Param token header string true "认证token" -// @Param payload formData string true "json数据,格式为OrdersSupplement" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddUpdateOrdersSupplement [post] -func (c *OrderController) AddUpdateOrdersSupplement() { - c.callAddUpdateOrdersSupplement(func(params *tOrderAddUpdateOrdersSupplementParams) (retVal interface{}, errCode string, err error) { - ordersSupplement := &model.OrderSupplementFee{} - if err = utils.UnmarshalUseNumber([]byte(params.Payload), ordersSupplement); err == nil { - retVal, err = orderman.AddUpdateOrdersSupplement(params.Ctx, ordersSupplement) - } - return retVal, "", err - }) -} - -// @Title 重新计算订单结算信息 -// @Description 重新计算订单结算信息 -// @Param token header string true "认证token" -// @Param fromTime formData string true "订单起始时间" -// @Param toTime formData string false "订单结束时间" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshOrdersPriceInfo [post] -func (c *OrderController) RefreshOrdersPriceInfo() { - c.callRefreshOrdersPriceInfo(func(params *tOrderRefreshOrdersPriceInfoParams) (retVal interface{}, errCode string, err error) { - timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime) - if err == nil { - retVal, err = orderman.RefreshOrdersPriceInfo(params.Ctx, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 获取某个门店订单中待拣货商品 -// @Description 获取某个门店订单中待拣货商品 -// @Param token header string true "认证token" -// @Param storeID query int true "门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOrdersAccept [get] -func (c *OrderController) GetOrdersAccept() { - c.callGetOrdersAccept(func(params *tOrderGetOrdersAcceptParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.GetOrdersAccept(params.Ctx, params.StoreID) - return retVal, "", err - }) -} - -// @Title 获取某个门店上次申请物料到现在的销量 -// @Description 获取某个门店上次申请物料到现在的销量 -// @Param token header string false "认证token" -// @Param storeID query int true "门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetMatterStoreOrderCount [get] -func (c *OrderController) GetMatterStoreOrderCount() { - c.callGetMatterStoreOrderCount(func(params *tOrderGetMatterStoreOrderCountParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.GetMatterStoreOrderCount(params.Ctx, params.StoreID) - return retVal, "", err - }) -} - -// @Title 刷新京东商城订单结算价 -// @Description 刷新京东商城订单结算价 -// @Param token header string true "认证token" -// @Param fromTime formData string true "订单起始时间 格式:20060102" -// @Param toTime formData string true "订单结束时间" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshJdShopOrdersEarningPrice [put] -func (c *OrderController) RefreshJdShopOrdersEarningPrice() { - c.callRefreshJdShopOrdersEarningPrice(func(params *tOrderRefreshJdShopOrdersEarningPriceParams) (retVal interface{}, errCode string, err error) { - err = orderman.RefreshJdShopOrdersEarningPrice(params.Ctx, params.FromTime, params.ToTime) - return retVal, "", err - }) -} - -// @Title 根据订单号查询一些信息 -// @Description 根据订单号查询一些信息 -// @Param token header string false "认证token" -// @Param vendorOrderID query string true "订单号" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOrderSimpleInfo [get] -func (c *OrderController) GetOrderSimpleInfo() { - c.callGetOrderSimpleInfo(func(params *tOrderGetOrderSimpleInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.GetOrderSimpleInfo(params.Ctx, params.VendorOrderID) - return retVal, "", err - }) -} - -// @Title 根据订单号查询用户是否是第一次购买 -// @Description 根据订单号查询用户是否是第一次购买 -// @Param token header string true "认证token" -// @Param vendorOrderID query string true "订单号" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOrderUserBuyFirst [get] -func (c *OrderController) GetOrderUserBuyFirst() { - c.callGetOrderUserBuyFirst(func(params *tOrderGetOrderUserBuyFirstParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.GetOrderUserBuyFirst(params.Ctx, params.VendorOrderID) - return retVal, "", err - }) -} - -// @Title 京东商城订单转移 -// @Description 京东商城订单转移 -// @Param token header string true "认证token" -// @Param storeID formData int true "转移的门店ID" -// @Param vendorOrderID formData string true "转移的订单号" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TransferJdsOrder [post] -func (c *OrderController) TransferJdsOrder() { - c.callTransferJdsOrder(func(params *tOrderTransferJdsOrderParams) (retVal interface{}, errCode string, err error) { - retVal, err = orderman.TransferJdsOrder(params.Ctx, params.VendorOrderID, params.StoreID) - return retVal, "", err - }) -} - -// @Title 合并订单(京东商城用) -// @Description 合并订单(京东商城用) -// @Param token header string true "认证token" -// @Param vendorOrderIDs formData string true "订单号s" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /MergeJdsOrders [post] -func (c *OrderController) MergeJdsOrders() { - c.callMergeJdsOrders(func(params *tOrderMergeJdsOrdersParams) (retVal interface{}, errCode string, err error) { - var vendorOrderIDs []string - if err = jxutils.Strings2Objs(params.VendorOrderIDs, &vendorOrderIDs); err == nil { - retVal, err = orderman.MergeJdsOrders(params.Ctx, vendorOrderIDs) - } - return retVal, "", err - }) -} - -// @Title 京东商城订单发送京东物流 -// @Description 京东商城订单发送京东物流 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单号" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SendJdwlForJdsOrder [post] -func (c *OrderController) SendJdwlForJdsOrder() { - c.callSendJdwlForJdsOrder(func(params *tOrderSendJdwlForJdsOrderParams) (retVal interface{}, errCode string, err error) { - err = orderman.SendJdwlForJdsOrder(params.Ctx, params.VendorOrderID) - return retVal, "", err - }) -} - -// @Title 手动拉取京东商城订单 -// @Description 手动拉取京东商城订单 -// @Param token header string true "认证token" -// @Param fromTime formData string true "订单起始时间" -// @Param toTime formData string true "订单结束时间" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SaveJdsOrders [post] -func (c *OrderController) SaveJdsOrders() { - c.callSaveJdsOrders(func(params *tOrderSaveJdsOrdersParams) (retVal interface{}, errCode string, err error) { - err = orderman.SaveJdsOrders(params.Ctx, utils.Str2Time(params.FromTime), utils.Str2Time(params.ToTime)) - return retVal, "", err - }) -} - -// @Title 针对京东商城进行简单的售前删除操作 -// @Description 针对京东商城进行简单的售前删除操作 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单号" -// @Param skuID formData int true "商品ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AdjustJdsOrderSimple [post] -func (c *OrderController) AdjustJdsOrderSimple() { - c.callAdjustJdsOrderSimple(func(params *tOrderAdjustJdsOrderSimpleParams) (retVal interface{}, errCode string, err error) { - err = orderman.AdjustJdsOrderSimple(params.Ctx, params.VendorOrderID, params.SkuID) - return retVal, "", err - }) -} - -// @Title 修改订单运费 -// @Description 修改订单运费 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单号" -// @Param desiredFee formData int true "运费" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateWaybillDesiredFee [put] -func (c *OrderController) UpdateWaybillDesiredFee() { - c.callUpdateWaybillDesiredFee(func(params *tOrderUpdateWaybillDesiredFeeParams) (retVal interface{}, errCode string, err error) { - err = orderman.UpdateWaybillDesiredFee(params.Ctx, params.VendorOrderID, params.DesiredFee) - return retVal, "", err - }) -} - -// @Title 接单或拒单 -// @Description 接单或拒单 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单平台ID" -// @Param isAccept formData bool true "接单或者拒单" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AcceptOrRefuseOrder [post] -func (c *OrderController) AcceptOrRefuseOrder() { - c.callAcceptOrRefuseOrder(func(params *tOrderAcceptOrRefuseOrderParams) (retVal interface{}, errCode string, err error) { - err = orderman.AcceptOrRefuseOrder(params.Ctx, params.VendorOrderID, params.VendorID, params.IsAccept) - return retVal, "", err - }) -} - -// @Title 刷新京东商城订单收货人信息 -// @Description 刷新京东商城订单收货人信息 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshJdsOrderConsigneeInfo [put] -func (c *OrderController) RefreshJdsOrderConsigneeInfo() { - c.callRefreshJdsOrderConsigneeInfo(func(params *tOrderRefreshJdsOrderConsigneeInfoParams) (retVal interface{}, errCode string, err error) { - err = orderman.RefreshJdsOrderConsigneeInfo(params.Ctx, params.VendorOrderID) - return retVal, "", err - }) -} - -// @Title 修改订单信息 -// @Description 修改订单信息 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单号" -// @Param vendorID formData int true "平台ID" -// @Param payload formData string true "json数据,格式为goodsOrder" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateOrderInfo [put] -func (c *OrderController) UpdateOrderInfo() { - c.callUpdateOrderInfo(func(params *tOrderUpdateOrderInfoParams) (retVal interface{}, errCode string, err error) { - payload := make(map[string]interface{}) - if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil { - retVal, err = orderman.UpdateOrderInfo(params.Ctx, params.VendorOrderID, params.VendorID, payload) - } - return retVal, "", err - }) -} diff --git a/controllers/jx_order2.go b/controllers/jx_order2.go deleted file mode 100644 index ffe35c94e..000000000 --- a/controllers/jx_order2.go +++ /dev/null @@ -1,286 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx" - "github.com/astaxie/beego" -) - -type JxOrderController struct { - beego.Controller -} - -// @Title 创建京西商城订单 -// @Description 创建京西商城订单 -// @Param token header string true "认证token" -// @Param jxOrder formData string true "订单信息" -// @Param addressID formData int64 true "配送地址ID" -// @Param fromStoreID formData int fasle "物料配送门店" -// @Param createType formData int false "创建类型, 0:预创建, 1:创建" -// @Param isDeliverySelf formData bool false "是否是自提单" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateOrder [post] -func (c *JxOrderController) CreateOrder() { - c.callCreateOrder(func(params *tJxorderCreateOrderParams) (retVal interface{}, errCode string, err error) { - var jxOrder *localjx.JxOrderInfo - if err = utils.UnmarshalUseNumber([]byte(params.JxOrder), &jxOrder); err == nil { - retVal, err = localjx.CreateOrder(params.Ctx, jxOrder, int64(params.AddressID), params.CreateType, params.FromStoreID, params.IsDeliverySelf) - } - return retVal, "", err - }) -} - -// @Title 请求支付京西商城订单 -// @Description 请求支付京西商城订单 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param payType formData int true "支付类型" -// @Param vendorPayType formData string true "平台支付类型" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /Pay4Order [post] -func (c *JxOrderController) Pay4Order() { - c.callPay4Order(func(params *tJxorderPay4OrderParams) (retVal interface{}, errCode string, err error) { - retVal, err = localjx.Pay4Order(params.Ctx, utils.Str2Int64(params.VendorOrderID), params.PayType, params.VendorPayType) - return retVal, "", err - }) -} - -// @Title 请求支付京西商城相关用户支付项目 -// @Description 请求支付京西商城相关用户支付项目 -// @Param token header string true "认证token" -// @Param thingID formData int true "项目ID" -// @Param payType formData int true "支付类型" -// @Param vendorPayType formData string true "平台支付类型" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /Pay4User [post] -func (c *JxOrderController) Pay4User() { - c.callPay4User(func(params *tJxorderPay4UserParams) (retVal interface{}, errCode string, err error) { - retVal, err = localjx.Pay4User(params.Ctx, params.ThingID, params.PayType, params.VendorPayType) - return retVal, "", err - }) -} - -// @Title 买家取消(或申请取消)订单 -// @Description 买家取消(或申请取消)订单 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param reason formData string true "原因" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /BuyerCancelOrder [post] -func (c *JxOrderController) BuyerCancelOrder() { - c.callBuyerCancelOrder(func(params *tJxorderBuyerCancelOrderParams) (retVal interface{}, errCode string, err error) { - retVal, err = localjx.BuyerCancelOrder(params.Ctx, utils.Str2Int64(params.VendorOrderID), params.Reason) - return retVal, "", err - }) -} - -// @Title 得到门店营业时间配送列表 -// @Description 得到门店营业时间配送列表 -// @Param token header string true "认证token" -// @Param storeID query int true "门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetAvailableDeliverTime [get] -func (c *JxOrderController) GetAvailableDeliverTime() { - c.callGetAvailableDeliverTime(func(params *tJxorderGetAvailableDeliverTimeParams) (retVal interface{}, errCode string, err error) { - retVal, err = localjx.GetAvailableDeliverTime(params.Ctx, params.StoreID) - return retVal, "", err - }) -} - -// @Title 得到一个订单的支付信息 -// @Description 得到一个订单的支付信息 -// @Param token header string true "认证token" -// @Param vendorOrderID query string true "订单号,如果此项不为空,忽略其它所有查询条件" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOrderPay [get] -func (c *JxOrderController) GetOrderPay() { - c.callGetOrderPay(func(params *tJxorderGetOrderPayParams) (retVal interface{}, errCode string, err error) { - retVal, err = localjx.GetOrderPay(params.Ctx, params.VendorOrderID) - return retVal, "", err - }) -} - -// @Title 查询自己的订单 -// @Description 查询自己的订单 -// @Param token header string true "认证token" -// @Param vendorOrderID query string false "订单号,如果此项不为空,忽略其它所有查询条件" -// @Param keyword query string false "查询关键字" -// @Param fromDate query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param toDate query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param statuss query string false "订单状态列表[1,2,3],缺省不限制" -// @Param offset query int false "结果起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetMyOrders [get] -func (c *JxOrderController) GetMyOrders() { - c.callGetMyOrders(func(params *tJxorderGetMyOrdersParams) (retVal interface{}, errCode string, err error) { - retVal, err = localjx.GetMyOrders(params.Ctx, params.FromDate, params.ToDate, params.MapData, params.Offset, params.PageSize) - return retVal, "", err - }) -} - -// @Title 查询自己的售后单 -// @Description 查询自己的售后单 -// @Param token header string true "认证token" -// @Param vendorOrderID query string false "订单号,如果此项不为空,忽略其它所有查询条件" -// @Param afsOrderID query string false "售后单号" -// @Param userID query string false "用户ID" -// @Param fromTime query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param toTime query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param offset query int false "结果起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetMyAfsOrders [get] -func (c *JxOrderController) GetMyAfsOrders() { - c.callGetMyAfsOrders(func(params *tJxorderGetMyAfsOrdersParams) (retVal interface{}, errCode string, err error) { - retVal, err = localjx.GetMyAfsOrders(params.Ctx, params.VendorOrderID, params.AfsOrderID, params.UserID, params.FromTime, params.ToTime, params.Offset, params.PageSize) - return retVal, "", err - }) -} - -// @Title 查询自己的订单状态数量信息 -// @Description 查询自己的订单状态数量信息 -// @Param token header string true "认证token" -// @Param fromDate query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param toDate query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param statuss query string false "订单状态列表[1,2,3],缺省不限制" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetMyOrderCountInfo [get] -func (c *JxOrderController) GetMyOrderCountInfo() { - c.callGetMyOrderCountInfo(func(params *tJxorderGetMyOrderCountInfoParams) (retVal interface{}, errCode string, err error) { - timeList, err := jxutils.BatchStr2Time(params.FromDate, params.ToDate) - if err == nil { - var statuss []int - if err = jxutils.Strings2Objs(params.Statuss, &statuss); err == nil { - retVal, err = localjx.GetMyOrderCountInfo(params.Ctx, timeList[0], timeList[1], statuss) - } - } - return retVal, "", err - }) -} - -// @Title 每日订单打款 -// @Description 每日订单打款 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AutoPayForPopluarMan [post] -func (c *JxOrderController) AutoPayForPopluarMan() { - c.callAutoPayForPopluarMan(func(params *tJxorderAutoPayForPopluarManParams) (retVal interface{}, errCode string, err error) { - err = localjx.AutoPayForPopluarMan(params.Ctx) - return retVal, "", err - }) -} - -// @Title 订单打款 -// @Description 订单打款 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Param userID formData string true "userID" -// @Param price formData int true "钱" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /PayForPopluarMan [post] -func (c *JxOrderController) PayForPopluarMan() { - c.callPayForPopluarMan(func(params *tJxorderPayForPopluarManParams) (retVal interface{}, errCode string, err error) { - err = localjx.PayForPopluarMan(params.Ctx, params.VendorOrderID, params.UserID, params.Price) - return retVal, "", err - }) -} - -// @Title 查询物料订单状态 -// @Description 查询物料订单状态 -// @Param token header string true "认证token" -// @Param vendorOrderID query string true "订单ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetMatterOrderStatus [get] -func (c *JxOrderController) GetMatterOrderStatus() { - c.callGetMatterOrderStatus(func(params *tJxorderGetMatterOrderStatusParams) (retVal interface{}, errCode string, err error) { - retVal, err = localjx.GetMatterOrderStatus(params.Ctx, params.VendorOrderID) - return retVal, "", err - }) -} - -// @Title 刷新所有物料订单状态 -// @Description 刷新所有物料订单状态 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshAllMatterOrderStatus [put] -func (c *JxOrderController) RefreshAllMatterOrderStatus() { - c.callRefreshAllMatterOrderStatus(func(params *tJxorderRefreshAllMatterOrderStatusParams) (retVal interface{}, errCode string, err error) { - err = localjx.RefreshAllMatterOrderStatus(params.Ctx) - return retVal, "", err - }) -} - -// @Title 重发物料订单 -// @Description 重发物料订单 -// @Param token header string true "认证token" -// @Param vendorOrderID formData string true "订单ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SendFailedMatterOrder [post] -func (c *JxOrderController) SendFailedMatterOrder() { - c.callSendFailedMatterOrder(func(params *tJxorderSendFailedMatterOrderParams) (retVal interface{}, errCode string, err error) { - err = localjx.SendFailedMatterOrder(params.Ctx, params.VendorOrderID) - return retVal, "", err - }) -} - -// @Title 根据时间获取进货辅助工具里的商品,用于加入购物车 -// @Description 根据时间获取进货辅助工具里的商品,用于加入购物车 -// @Param token header string true "认证token" -// @Param fromDate query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param toDate query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param fromStoreID query int false "进货门店ID" -// @Param storeID query int false "货源门店ID" -// @Param percentage query string false "销量比例,1,1.05,1.1" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetSupplySupportStoreSkus [get] -func (c *JxOrderController) GetSupplySupportStoreSkus() { - c.callGetSupplySupportStoreSkus(func(params *tJxorderGetSupplySupportStoreSkusParams) (retVal interface{}, errCode string, err error) { - retVal, err = localjx.GetSupplySupportStoreSkus(params.Ctx, params.FromDate, params.ToDate, params.FromStoreID, params.StoreID, params.Percentage) - return retVal, "", err - }) -} - -// @Title 得到自己的守价订单列表 -// @Description 得到自己的守价订单列表 -// @Param token header string true "认证token" -// @Param fromTime query string false "开始日期(包含),格式(2006-01-02 00:00:00)" -// @Param toTime query string false "结束日期(包含),格式(2006-01-02 00:00:00)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetMyPriceDefendOrders [get] -func (c *JxOrderController) GetMyPriceDefendOrders() { - c.callGetMyPriceDefendOrders(func(params *tJxorderGetMyPriceDefendOrdersParams) (retVal interface{}, errCode string, err error) { - retVal, err = localjx.GetMyPriceDefendOrders(params.Ctx, params.FromTime, params.ToTime) - return retVal, "", err - }) -} - -// @Title 测试立马生成守价订单 -// @Description 测试立马生成守价订单 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TestDefend [get] -func (c *JxOrderController) TestDefend() { - c.callTestDefend(func(params *tJxorderTestDefendParams) (retVal interface{}, errCode string, err error) { - err = localjx.CreateOrderByPriceDefend(params.Ctx) - return retVal, "", err - }) -} diff --git a/controllers/jx_report.go b/controllers/jx_report.go deleted file mode 100644 index 7966917de..000000000 --- a/controllers/jx_report.go +++ /dev/null @@ -1,98 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxstore/report" - "git.rosy.net.cn/jx-callback/business/jxutils" - "github.com/astaxie/beego" -) - -// 统计相关API -type ReportController struct { - beego.Controller -} - -// @Title 查询订单统计信息 -// @Description 根据门店idlist和时间范围查询 -// @Param token header string true "认证token" -// @Param storeIDs formData string true "京西门店ID列表[1,2,3]" -// @Param fromDate formData string true "开始日期(包含),格式(2006-01-02 00:00:00)" -// @Param toDate formData string true "结束日期(包含),格式(2006-01-02 00:00:00)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /StatisticsReportForOrders [post] -func (c *ReportController) StatisticsReportForOrders() { - c.callStatisticsReportForOrders(func(params *tReportStatisticsReportForOrdersParams) (retVal interface{}, errCode string, err error) { - var storeIDList []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil { - retVal, err = report.GetStatisticsReportForOrders(params.Ctx, storeIDList, params.FromDate, params.ToDate) - } - return retVal, "", err - }) -} - -// @Title 查询售后单统计信息 -// @Description 根据门店idlist和时间范围查询 -// @Param token header string true "认证token" -// @Param storeIDs formData string true "京西门店ID列表[1,2,3]" -// @Param fromDate formData string true "开始日期(包含),格式(2006-01-02 00:00:00)" -// @Param toDate formData string true "结束日期(包含),格式(2006-01-02 00:00:00)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /StatisticsReportForAfsOrders [post] -func (c *ReportController) StatisticsReportForAfsOrders() { - c.callStatisticsReportForAfsOrders(func(params *tReportStatisticsReportForAfsOrdersParams) (retVal interface{}, errCode string, err error) { - var storeIDList []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil { - retVal, err = report.GetStatisticsReportForAfsOrders(params.Ctx, storeIDList, params.FromDate, params.ToDate) - } - return retVal, "", err - }) -} - -// @Title 查询京西门店商品价格统计相关信息 -// @Description 查询京西门店商品价格统计相关信息 -// @Param token header string true "认证token" -// @Param cityCodes formData string true "城市ID列表[1,2,3]" -// @Param skuIDs formData string false "skuID列表[1,2,3]" -// @Param snapDate formData string true "某天的参考价格 格式:2006-01-02,默认前一天" -// @Param offset formData int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize formData int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /StatisticsReportForStoreSkusPrice [post] -func (c *ReportController) StatisticsReportForStoreSkusPrice() { - c.callStatisticsReportForStoreSkusPrice(func(params *tReportStatisticsReportForStoreSkusPriceParams) (retVal interface{}, errCode string, err error) { - var cityCodeList, skuIDList []int - if err = jxutils.Strings2Objs(params.CityCodes, &cityCodeList, params.SkuIDs, &skuIDList); err == nil { - retVal, err = report.StatisticsReportForStoreSkusPrice(params.Ctx, cityCodeList, skuIDList, params.SnapDate, params.Offset, params.PageSize) - } - return retVal, "", err - }) -} - -// @Title 生成价格参考数据 -// @Description 生成价格参考数据 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /PriceRefer [post] -func (c *ReportController) PriceRefer() { - c.callPriceRefer(func(params *tReportPriceReferParams) (retVal interface{}, errCode string, err error) { - report.BeginSavePriceRefer(params.Ctx, nil, nil, true, true) - return retVal, "", err - }) -} - -// @Title 自动关注商品(针对后加的商品规格未关注) -// @Description 自动关注商品(针对后加的商品规格未关注) -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AutoFocusStoreSkus [post] -func (c *ReportController) AutoFocusStoreSkus() { - c.callAutoFocusStoreSkus(func(params *tReportAutoFocusStoreSkusParams) (retVal interface{}, errCode string, err error) { - cms.AutoFocusStoreSkusWithoutFocus(params.Ctx, nil, false) - return retVal, "", err - }) -} diff --git a/controllers/jxshop_callback.go b/controllers/jxshop_callback.go deleted file mode 100644 index 911f9a365..000000000 --- a/controllers/jxshop_callback.go +++ /dev/null @@ -1,33 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/jx-callback/business/partner/purchase/jx/phpjx" - "github.com/astaxie/beego" -) - -type JxShopController struct { - beego.Controller -} - -// @Title 京西自营商城消息回调接口 -// @Description 京西自营商城消息回调接口 -// @Param appKey formData string true "AppKey" -// @Param msgType formData string true "消息类型" -// @Param subMsgType formData string false "子消息类型" -// @Param thingID formData string false "消息对应的事物ID" -// @Param data formData string false "详细" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /JxMsg [post] -func (c *JxShopController) JxMsg(msgType string) { - c.callJxMsg(func(params *tJxshopJxMsgParams) (retVal interface{}, errCode string, err error) { - retVal, errCode, err = phpjx.OnCallbackMsg(&phpjx.CallbackMsg{ - AppKey: params.AppKey, - MsgType: params.MsgType, - SubMsgType: params.SubMsgType, - ThingID: params.ThingID, - Data: params.Data, - }) - return retVal, "", err - }) -} diff --git a/controllers/mtps_order.go b/controllers/mtps_order.go deleted file mode 100644 index b5b8d04fe..000000000 --- a/controllers/mtps_order.go +++ /dev/null @@ -1,58 +0,0 @@ -package controllers - -import ( - "net/http" - - "git.rosy.net.cn/jx-callback/business/partner/delivery/mtps" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego" -) - -// Operations about ELMOrder -type MtpsController struct { - beego.Controller -} - -func (c *MtpsController) Status() { - if c.Ctx.Input.Method() == http.MethodPost { - if c.GetString("exception_id") != "" { // 美团配送的回调设置好象有问题,配送异常也会发到这里来,作一下兼容处理 - c.Except() - return - } - - obj, callbackResponse := api.MtpsAPI.GetOrderCallbackMsg(c.Ctx.Request) - if callbackResponse == nil { - callbackResponse = mtps.OnWaybillMsg(obj) - } - c.Data["json"] = callbackResponse - c.ServeJSON() - } else { - c.Abort("404") - } -} - -func (c *MtpsController) Except() { - if c.Ctx.Input.Method() == http.MethodPost { - obj, callbackResponse := api.MtpsAPI.GetOrderExceptionCallbackMsg(c.Ctx.Request) - if callbackResponse == nil { - callbackResponse = mtps.OnWaybillExcept(obj) - } - c.Data["json"] = callbackResponse - c.ServeJSON() - } else { - c.Abort("404") - } -} - -func (c *MtpsController) StoreStatus() { - if c.Ctx.Input.Method() == http.MethodPost { - obj, callbackResponse := api.MtpsAPI.GetShopStatusCallbackMsg(c.Ctx.Request) - if callbackResponse == nil { - callbackResponse = mtps.OnStoreStatus(obj) - } - c.Data["json"] = callbackResponse - c.ServeJSON() - } else { - c.Abort("404") - } -} diff --git a/controllers/mtwm_callback.go b/controllers/mtwm_callback.go deleted file mode 100644 index 4bd0b4683..000000000 --- a/controllers/mtwm_callback.go +++ /dev/null @@ -1,77 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/baseapi/platformapi/mtwmapi" - "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego" -) - -type MtwmController struct { - beego.Controller -} - -func (c *MtwmController) onCallbackMsg(msgType string) { - c.Data["json"] = mtwmapi.Err2CallbackResponse(nil, "") - msg, callbackResponse := api.MtwmAPI.GetCallbackMsg(c.Ctx.Request) - if callbackResponse == nil { - callbackResponse = mtwm.OnCallbackMsg(msg) - if callbackResponse == nil { - callbackResponse = mtwmapi.Err2CallbackResponse(nil, "") - } - } - c.Data["json"] = callbackResponse - c.ServeJSON() -} - -func (c *MtwmController) WaybillStatus() { - c.onCallbackMsg(mtwmapi.MsgTypeWaybillStatus) -} - -func (c *MtwmController) NewOrder() { - c.onCallbackMsg(mtwmapi.MsgTypeNewOrder) -} - -func (c *MtwmController) OrderAccepted() { - c.onCallbackMsg(mtwmapi.MsgTypeOrderAccepted) -} - -func (c *MtwmController) OrderFinished() { - c.onCallbackMsg(mtwmapi.MsgTypeOrderFinished) -} - -func (c *MtwmController) OrderFinancial() { - c.onCallbackMsg(mtwmapi.MsgTypeOrderFinancial) -} - -func (c *MtwmController) UserUrgeOrder() { - c.onCallbackMsg(mtwmapi.MsgTypeUserUrgeOrder) -} - -func (c *MtwmController) NumberDowngrade() { - c.onCallbackMsg(mtwmapi.MsgTypePrivateNumberDowngrade) -} - -func (c *MtwmController) OrderModified() { - c.onCallbackMsg(mtwmapi.MsgTypeOrderModified) -} - -func (c *MtwmController) OrderCanceled() { - c.onCallbackMsg(mtwmapi.MsgTypeOrderCanceled) -} - -func (c *MtwmController) OrderRefund() { - c.onCallbackMsg(mtwmapi.MsgTypeOrderRefund) -} - -func (c *MtwmController) OrderPartialRefund() { - c.onCallbackMsg(mtwmapi.MsgTypeOrderPartialRefund) -} - -func (c *MtwmController) StoreStatusChanged() { - c.onCallbackMsg(mtwmapi.MsgTypeStoreStatusChanged) -} - -func (c *MtwmController) OrderFinishedPickup() { - c.onCallbackMsg(mtwmapi.MsgTypeOrderFinishedPickup) -} diff --git a/controllers/net_spider.go b/controllers/net_spider.go deleted file mode 100644 index 4c40ae0f1..000000000 --- a/controllers/net_spider.go +++ /dev/null @@ -1,151 +0,0 @@ -package controllers - -import ( - "fmt" - "sort" - - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/model/dao" - "git.rosy.net.cn/jx-callback/business/netspider" - "github.com/astaxie/beego" -) - -type NetSpiderController struct { - beego.Controller -} - -// @Title 从网页拉取平台门店信息 -// @Description 从网页拉取平台门店信息 -// @Param token header string true "认证token" -// @Param vendorIDs formData string false "厂商ID列表" -// @Param cityCodes formData string false "城市列表,缺省为后台启用了的城市" -// @Param radius formData int false "区域半径(市或街道的半径会自动增加或缩小),单位为米,缺省8000米" -// @Param gridWith formData int false "网格大小,单位为米,缺省为2000米" -// @Param isShuffle formData bool false "是否将城市列表随机打乱" -// @Param isAsync formData bool false "是否异步" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetAndStoreCitiesShops [post] -func (c *NetSpiderController) GetAndStoreCitiesShops() { - c.callGetAndStoreCitiesShops(func(params *tNetspiderGetAndStoreCitiesShopsParams) (retVal interface{}, errCode string, err error) { - var vendorIDs, cityCodes []int - err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs, params.CityCodes, &cityCodes) - if err == nil { - retVal, err = netspider.GetAndStoreCitiesShops(params.Ctx, vendorIDs, cityCodes, params.Radius, params.GridWith, params.IsShuffle, params.IsAsync) - } - return retVal, "", err - }) -} - -// @Title 同步商家商品信息 -// @Description 同步商家商品信息 -// @Param token header string true "认证token" -// @Param offset query int false "列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "列表页大小(缺省为50,-1表示全部)" -// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)" -// @Param vendorStoreID query string false "门店号" -// @Param vendorID query int false "平台ID" -// @Param orgCode query string false "连锁品牌名" -// @Param cityCode query int false "城市代码" -// @Param districtCode query int false "行政区代码" -// @Param tel query string false "手机号" -// @Param minShopScore query float64 false "门店分值最小值" -// @Param minRecentOrderNum query int false "最近单量最小值" -// @Param minSkuCount query int false "SKU数量最小值" -// @Param radius query int false "关注点半径(米)" -// @Param lng query string false "关注点经度" -// @Param lat query string false "关注点纬度" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /QueryPageStores [get] -func (c *NetSpiderController) QueryPageStores() { - c.callQueryPageStores(func(params *tNetspiderQueryPageStoresParams) (retVal interface{}, errCode string, err error) { - if params.MapData["vendorID"] == nil { - params.VendorID = -1 - } - var lng, lat, lng1, lat1, lng2, lat2 float64 - params.Offset = jxutils.FormalizePageOffset(params.Offset) - params.PageSize = jxutils.FormalizePageSize(params.PageSize) - offset := params.Offset - pageSize := params.PageSize - if params.Radius > 0 { - lng = utils.Str2Float64WithDefault(params.Lng, 0) - lat = utils.Str2Float64WithDefault(params.Lat, 0) - if lng == 0 || lat == 0 { - return nil, "", fmt.Errorf("坐标信息%s,%s不合法", params.Lng, params.Lat) - } - lng2, _ = jxutils.ConvertDistanceToLogLat(lng, lat, float64(params.Radius), 90) - _, lat2 = jxutils.ConvertDistanceToLogLat(lng, lat, float64(params.Radius), 0) - lng1 = lng - (lng2 - lng) - lat1 = lat - (lat2 - lat) - offset = 0 - pageSize = model.UnlimitedPageSize - } - pagedInfo, err := dao.QueryPageStores(dao.GetDB(), pageSize, offset, params.Keyword, params.VendorStoreID, params.VendorID, params.OrgCode, - params.CityCode, params.DistrictCode, params.Tel, float32(params.MinShopScore), params.MinRecentOrderNum, params.MinSkuCount, - lng1, lat1, lng2, lat2) - if err == nil { - if params.Radius > 0 && (params.Offset != 0 || params.PageSize != model.UnlimitedPageSize) { - shopList2, _ := pagedInfo.Data.([]*dao.PageShopWithPlaceName) - var shopList []*dao.PageShopWithPlaceName - pagedInfo.TotalCount = 0 - if len(shopList2) > 0 { - for _, v := range shopList2 { - v.Distance = int(jxutils.EarthDistance(v.Lng, v.Lat, lng, lat) * 1000) - if v.Distance < 0 { - v.Distance = 0 - } - if v.Distance <= params.Radius { - shopList = append(shopList, v) - } - } - pagedInfo.TotalCount = len(shopList) - if pagedInfo.TotalCount > 0 { - sort.Sort(PageShopList(shopList)) - if params.Offset < len(shopList) { - index := params.Offset + params.PageSize - if index > len(shopList) { - index = len(shopList) - } - shopList = shopList[params.Offset:index] - } else { - shopList = nil - } - } - } - pagedInfo.Data = shopList - } - retVal = pagedInfo - } - return retVal, "", err - }) -} - -type PageShopList []*dao.PageShopWithPlaceName - -func (l PageShopList) Len() int { - return len(l) -} - -func (l PageShopList) Less(i, j int) bool { - return l[i].Distance < l[j].Distance -} - -func (l PageShopList) Swap(i, j int) { - l[i], l[j] = l[j], l[i] -} - -// @Title 刷新网页门店信息 -// @Description 刷新网页门店信息 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshPageShops [post] -func (c *NetSpiderController) RefreshPageShops() { - c.callRefreshPageShops(func(params *tNetspiderRefreshPageShopsParams) (retVal interface{}, errCode string, err error) { - err = netspider.RefreshPageShops(params.Ctx) - return retVal, "", err - }) -} diff --git a/controllers/permission.go b/controllers/permission.go deleted file mode 100644 index d149b5715..000000000 --- a/controllers/permission.go +++ /dev/null @@ -1,175 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/model" - "github.com/astaxie/beego" -) - -type PowerController struct { - beego.Controller -} - -// @Title 添加功能(菜单) -// @Description 添加功能(菜单) -// @Param token header string true "认证token" -// @Param payload formData string true "Menu json实体" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddMenu [post] -func (c *PowerController) AddMenu() { - c.callAddMenu(func(params *tPowerAddMenuParams) (retVal interface{}, errCode string, err error) { - menu := &model.Menu{} - if err = utils.UnmarshalUseNumber([]byte(params.Payload), menu); err == nil { - err = cms.AddMenu(params.Ctx, menu) - } - return retVal, "", err - }) -} - -// @Title 查询功能(菜单) -// @Description 查询功能(菜单) -// @Param token header string true "认证token" -// @Param userID query string false "用户ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetMenu [get] -func (c *PowerController) GetMenu() { - c.callGetMenu(func(params *tPowerGetMenuParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetMenu(params.Ctx, params.UserID) - return retVal, "", err - }) -} - -// @Title 修改功能(菜单) -// @Description 修改功能(菜单) -// @Param token header string true "认证token" -// @Param payload formData string true "Menu json实体" -// @Param menuID formData int true "菜单ID" -// @Param isDelete formData bool true "是否是删除" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateMenu [put] -func (c *PowerController) UpdateMenu() { - c.callUpdateMenu(func(params *tPowerUpdateMenuParams) (retVal interface{}, errCode string, err error) { - payload := make(map[string]interface{}) - if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil { - retVal, err = cms.UpdateMenu(params.Ctx, params.MenuID, payload, params.IsDelete) - } - return retVal, "", err - }) -} - -// @Title 添加角色 -// @Description 添加角色 -// @Param token header string true "认证token" -// @Param name formData string true "角色名" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddRole [post] -func (c *PowerController) AddRole() { - c.callAddRole(func(params *tPowerAddRoleParams) (retVal interface{}, errCode string, err error) { - err = cms.AddRole(params.Ctx, params.Name) - return retVal, "", err - }) -} - -// @Title 查询角色 -// @Description 查询角色 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetRole [get] -func (c *PowerController) GetRole() { - c.callGetRole(func(params *tPowerGetRoleParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetRole(params.Ctx) - return retVal, "", err - }) -} - -// @Title 修改角色 -// @Description 修改角色 -// @Param token header string true "认证token" -// @Param name formData string true "角色名" -// @Param roleID formData int true "角色ID" -// @Param isDelete formData bool true "是否是删除" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateRole [put] -func (c *PowerController) UpdateRole() { - c.callUpdateRole(func(params *tPowerUpdateRoleParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.UpdateRole(params.Ctx, params.RoleID, params.Name, params.IsDelete) - return retVal, "", err - }) -} - -// @Title 查询用户角色 -// @Description查询用户角色 -// @Param token header string true "认证token" -// @Param userID query string false "用户ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetUserRole [get] -func (c *PowerController) GetUserRole() { - c.callGetUserRole(func(params *tPowerGetUserRoleParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetUserRole(params.Ctx, params.UserID) - return retVal, "", err - }) -} - -// @Title 修改用户角色 -// @Description 修改用户角色 -// @Param token header string true "认证token" -// @Param userIDs formData string true "用户IDs" -// @Param roleIDs formData string true "角色IDs" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateUserRole [put] -func (c *PowerController) UpdateUserRole() { - c.callUpdateUserRole(func(params *tPowerUpdateUserRoleParams) (retVal interface{}, errCode string, err error) { - var ( - userIDs []string - roleIDs []int - ) - if err = jxutils.Strings2Objs(params.UserIDs, &userIDs, params.RoleIDs, &roleIDs); err == nil { - err = cms.UpdateUserRole(params.Ctx, userIDs, roleIDs) - } - return retVal, "", err - }) -} - -// @Title 查询角色菜单 -// @Description 查询角色菜单 -// @Param token header string true "认证token" -// @Param roleID query int false "用户ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetRoleMenu [get] -func (c *PowerController) GetRoleMenu() { - c.callGetRoleMenu(func(params *tPowerGetRoleMenuParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetRoleMenu(params.Ctx, params.RoleID) - return retVal, "", err - }) -} - -// @Title 修改角色菜单 -// @Description 修改角色菜单 -// @Param token header string true "认证token" -// @Param roleIDs formData string true "角色IDs" -// @Param menuIDs formData string true "菜单IDs" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateRoleMenu [put] -func (c *PowerController) UpdateRoleMenu() { - c.callUpdateRoleMenu(func(params *tPowerUpdateRoleMenuParams) (retVal interface{}, errCode string, err error) { - var ( - roleIDs, menuIDs []int - ) - if err = jxutils.Strings2Objs(params.RoleIDs, &roleIDs, params.MenuIDs, &menuIDs); err == nil { - err = cms.UpdateRoleMenu(params.Ctx, roleIDs, menuIDs) - } - return retVal, "", err - }) -} diff --git a/controllers/sys.go b/controllers/sys.go deleted file mode 100644 index 089f2156f..000000000 --- a/controllers/sys.go +++ /dev/null @@ -1,126 +0,0 @@ -package controllers - -import ( - "io" - "net/http" - "net/url" - "strings" - "time" - - "git.rosy.net.cn/baseapi/platformapi/ebaiapi" - - "git.rosy.net.cn/jx-callback/globals" - - "git.rosy.net.cn/jx-callback/business/jxutils/eventhub/syseventhub" - "git.rosy.net.cn/jx-callback/business/model" - "github.com/astaxie/beego" -) - -type SysController struct { - beego.Controller -} - -// @Title 得到微信token -// @Description 得到微信token -// @Param accessKey query string true "假token" -// @Param oldToken query string false "之前的token" -// @Param waitSecond query int false "等待秒数" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetWXToken [get] -func (c *SysController) GetWXToken() { - c.callGetWXToken(func(params *tSysGetWXTokenParams) (retVal interface{}, errCode string, err error) { - if params.AccessKey == globals.GetWeixinTokenKey { - retVal = syseventhub.SysEventHub.GetWXToken(params.OldToken, time.Duration(params.WaitSecond)*time.Second) - } - return retVal, "", err - }) -} - -// @Title 得到微信小程序2token -// @Description 得到微信小程序2token -// @Param accessKey query string true "假token" -// @Param oldToken query string false "之前的token" -// @Param waitSecond query int false "等待秒数" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetWX2Token [get] -func (c *SysController) GetWX2Token() { - c.callGetWX2Token(func(params *tSysGetWX2TokenParams) (retVal interface{}, errCode string, err error) { - if params.AccessKey == globals.GetWeixinTokenKey { - retVal = syseventhub.SysEventHub.GetWX2Token(params.OldToken, time.Duration(params.WaitSecond)*time.Second) - } - return retVal, "", err - }) -} - -// @Title 得到易联云token -// @Description 得到易联云token -// @Param accessKey query string true "假token" -// @Param oldToken query string false "之前的token" -// @Param waitSecond query int false "等待秒数" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetYLYToken [get] -func (c *SysController) GetYLYToken() { - c.callGetYLYToken(func(params *tSysGetYLYTokenParams) (retVal interface{}, errCode string, err error) { - if params.AccessKey == globals.GetWeixinTokenKey { - retVal = syseventhub.SysEventHub.GetYLYToken(params.OldToken, time.Duration(params.WaitSecond)*time.Second) - } - return retVal, "", err - }) -} - -// @Title 得到个推token -// @Description 得到个推token -// @Param accessKey query string true "假token" -// @Param oldToken query string false "之前的token" -// @Param waitSecond query int false "等待秒数" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetPushToken [get] -func (c *SysController) GetPushToken() { - c.callGetPushToken(func(params *tSysGetPushTokenParams) (retVal interface{}, errCode string, err error) { - if params.AccessKey == globals.GetWeixinTokenKey { - retVal = syseventhub.SysEventHub.GetPushToken(params.OldToken, time.Duration(params.WaitSecond)*time.Second) - } - return retVal, "", err - }) -} - -// @Title 得到微盟token -// @Description 得到微盟token -// @Param accessKey query string true "假token" -// @Param oldToken query string false "之前的token" -// @Param waitSecond query int false "等待秒数" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetWeimobToken [get] -func (c *SysController) GetWeimobToken() { - c.callGetWeimobToken(func(params *tSysGetWeimobTokenParams) (retVal interface{}, errCode string, err error) { - if params.AccessKey == globals.GetWeixinTokenKey { - retVal = syseventhub.SysEventHub.GetWeimobToken(params.OldToken, time.Duration(params.WaitSecond)*time.Second) - } - return retVal, "", err - }) -} - -// @Title 得到饿百RTF转换内容 -// @Description 得到饿百RTF转换内容 -// @Param imgListStr query string true "逗号分隔的图片列表可以是转义后的" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetEbaiRTFDetail [get] -func (c *SysController) GetEbaiRTFDetail() { - var html string - c.callGetEbaiRTFDetail(func(params *tSysGetEbaiRTFDetailParams) (retVal interface{}, errCode string, err error) { - params.ImgListStr, _ = url.QueryUnescape(params.ImgListStr) - imgList := strings.Split(params.ImgListStr, ",") - html = ebaiapi.BuildRFTFromImgs(imgList...) - return retVal, model.ErrorCodeIgnore, err - }) - w := c.Ctx.ResponseWriter - w.Header().Add("Content-Type", "text/html") - w.WriteHeader(http.StatusOK) - io.WriteString(w, html) -} diff --git a/controllers/temp_op.go b/controllers/temp_op.go deleted file mode 100644 index d9e55c8ab..000000000 --- a/controllers/temp_op.go +++ /dev/null @@ -1,433 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxstore/misc" - "git.rosy.net.cn/jx-callback/business/jxstore/tempop" - "git.rosy.net.cn/jx-callback/business/jxutils" - "github.com/astaxie/beego" -) - -type TempOpController struct { - beego.Controller -} - -// @Title 将为份的商品在京东转成SPU -// @Description 将为份的商品在京东转成SPU -// @Param token header string true "认证token" -// @Param count formData int false "转换的数量,缺省0表示全部" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /Convert2JDSPU [post] -func (c *InitDataController) Convert2JDSPU() { - c.callConvert2JDSPU(func(params *tInitdataConvert2JDSPUParams) (retVal interface{}, errCode string, err error) { - retVal, err = tempop.Convert2JDSPU(params.Ctx, params.Count, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 将京东商店为份的SPU转换 -// @Description 将京东商店为份的SPU转换 -// @Param token header string true "认证token" -// @Param step formData int true "门店列表" -// @Param storeIDs formData string false "门店列表" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /Change2JDSPU4Store [post] -func (c *InitDataController) Change2JDSPU4Store() { - c.callChange2JDSPU4Store(func(params *tInitdataChange2JDSPU4StoreParams) (retVal interface{}, errCode string, err error) { - var storeIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil { - retVal, err = tempop.Change2JDSPU4Store(params.Ctx, storeIDs, params.Step, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// // @Title 将遗留JD订单合并 -// // @Description 将遗留JD订单合并 -// // @Param token header string true "认证token" -// // @Param isAsync formData bool false "是否异步操作" -// // @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// // @Success 200 {object} controllers.CallResult -// // @Failure 200 {object} controllers.CallResult -// // @router /TransferLegacyJdOrder [post] -// func (c *InitDataController) TransferLegacyJdOrder() { -// c.callTransferLegacyJdOrder(func(params *tInitdataTransferLegacyJdOrderParams) (retVal interface{}, errCode string, err error) { -// retVal, err = tempop.TransferLegacyJdOrder(params.Ctx, params.IsAsync, params.IsContinueWhenError) -// return retVal, "", err -// }) -// } - -// // @Title 将goods_order中缺失的订单从goods_order_original中恢复 -// // @Description 将goods_order中缺失的订单从goods_order_original中恢复 -// // @Param token header string true "认证token" -// // @Param isAsync formData bool false "是否异步操作" -// // @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// // @Success 200 {object} controllers.CallResult -// // @Failure 200 {object} controllers.CallResult -// // @router /CreateOrderFromOriginal [post] -// func (c *InitDataController) CreateOrderFromOriginal() { -// c.callCreateOrderFromOriginal(func(params *tInitdataCreateOrderFromOriginalParams) (retVal interface{}, errCode string, err error) { -// retVal, err = tempop.CreateOrderFromOriginal(params.Ctx, params.IsAsync, params.IsContinueWhenError) -// return retVal, "", err -// }) -// } - -// @Title 拉取京东订单补齐本地 -// @Description 拉取京东订单补齐本地 -// @Param token header string true "认证token" -// @Param fromTime formData string true "开始时间" -// @Param toTime formData string true "结束时间" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /PullJdOrder [post] -func (c *InitDataController) PullJdOrder() { - c.callPullJdOrder(func(params *tInitdataPullJdOrderParams) (retVal interface{}, errCode string, err error) { - timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime) - if err != nil { - return retVal, "", err - } - retVal, err = tempop.PullJdOrder(params.Ctx, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 删除错误创建的SPU -// @Description 删除错误创建的SPU -// @Param token header string true "认证token" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteWrongSpu [delete] -func (c *InitDataController) DeleteWrongSpu() { - c.callDeleteWrongSpu(func(params *tInitdataDeleteWrongSpuParams) (retVal interface{}, errCode string, err error) { - retVal, err = tempop.DeleteWrongSpu(params.Ctx, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 将京东的SPU转为非SPU,保持转后的SKU商家自编号不变 -// @Description 将京东的SPU转为非SPU,保持转后的SKU商家自编号不变 -// @Param token header string true "认证token" -// @Param nameIDs formData string false "需要转换的nameID列表,缺省空表示全部" -// @Param count formData int false "转换的数量,缺省0表示全部(按ID排序)" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TransformJdSpu2Sku [post] -func (c *InitDataController) TransformJdSpu2Sku() { - c.callTransformJdSpu2Sku(func(params *tInitdataTransformJdSpu2SkuParams) (retVal interface{}, errCode string, err error) { - var nameIDs []int - if err = jxutils.Strings2Objs(params.NameIDs, &nameIDs); err != nil { - return retVal, "", err - } - retVal, err = tempop.TransformJdSpu2Sku(params.Ctx, nameIDs, params.Count, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 重新处理京东差评 -// @Description 重新处理京东差评 -// @Param token header string true "认证token" -// @Param isForce formData bool false "是否强制处理" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ReProcessJdBadComment [post] -func (c *InitDataController) ReProcessJdBadComment() { - c.callReProcessJdBadComment(func(params *tInitdataReProcessJdBadCommentParams) (retVal interface{}, errCode string, err error) { - retVal, err = tempop.ReProcessJdBadComment(params.Ctx, params.IsForce, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 刷新 -// @Description 重新处理京东差评 -// @Param token header string true "认证token" -// @Param fromTime formData string false "起始时间" -// @Param toTime formData string false "结束时间" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshEbaiBadComment [post] -func (c *InitDataController) RefreshEbaiBadComment() { - c.callRefreshEbaiBadComment(func(params *tInitdataRefreshEbaiBadCommentParams) (retVal interface{}, errCode string, err error) { - if timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime); err == nil { - retVal, err = tempop.RefreshEbaiBadComment(params.Ctx, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 测试打印 -// @Description 测试打印 -// @Param token header string true "认证token" -// @Param vendorID formData int true "打印机厂商ID" -// @Param id1 formData string true "id1" -// @Param id2 formData string false "id2" -// @Param msgTitle formData string false "消息标题" -// @Param msgContent formData string true "消息内容" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /PrintMsg [post] -func (c *TempOpController) PrintMsg() { - c.callPrintMsg(func(params *tTempopPrintMsgParams) (retVal interface{}, errCode string, err error) { - retVal, err = tempop.PrintMsg(params.Ctx, params.VendorID, params.Id1, params.Id2, params.MsgTitle, params.MsgContent) - return retVal, "", err - }) -} - -// @Title 刷新微信备注 -// @Description 刷新微信备注 -// @Param token header string true "认证token" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateAllWeiXinRemark [post] -func (c *TempOpController) UpdateAllWeiXinRemark() { - c.callUpdateAllWeiXinRemark(func(params *tTempopUpdateAllWeiXinRemarkParams) (retVal interface{}, errCode string, err error) { - retVal, err = tempop.UpdateAllWeiXinRemark(params.Ctx, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title XXXX -// @Description XXXX -// @Param token header string true "认证token" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RetrieveEbaiShopLicence [post] -func (c *TempOpController) RetrieveEbaiShopLicence() { - c.callRetrieveEbaiShopLicence(func(params *tTempopRetrieveEbaiShopLicenceParams) (retVal interface{}, errCode string, err error) { - retVal, err = tempop.RetrieveEbaiShopLicence(params.Ctx, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 刷新美团配送价格 -// @Description 刷新美团配送价格 -// @Param token header string true "认证token" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshMtpsWaybillFee [post] -func (c *TempOpController) RefreshMtpsWaybillFee() { - c.callRefreshMtpsWaybillFee(func(params *tTempopRefreshMtpsWaybillFeeParams) (retVal interface{}, errCode string, err error) { - retVal, err = tempop.RefreshMtpsWaybillFee(params.Ctx, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 查询三方运单费用信息 -// @Description 查询三方运单费用信息 -// @Param token header string true "认证token" -// @Param isAsync query bool false "是否异步操作" -// @Param isContinueWhenError query bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TestIt [get] -func (c *TempOpController) TestIt() { - c.callTestIt(func(params *tTempopTestItParams) (retVal interface{}, errCode string, err error) { - retVal, err = tempop.CheckImages(params.Ctx, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 开启或结束所有平台商店的额外时间 -// @Description 开启或结束所有平台商店的额外时间,并且修改所有商品库存为0或99999(开启:0 , 结束:99999) -// @Param token header string true "认证token" -// @Param vendorIDs formData string false "运营商ID列表(美团1 饿百3)" -// @Param storeIDs formData string false "京西门店ID列表" -// @Param startOrEndStore formData bool true "开启或结束" -// @Param startTime formData int false "开始营业时间(格式:930代表早上9点30分)" -// @Param endTime formData int false "结束营业时间" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TestStartOrEndOpStore [post] -func (c *TempOpController) TestStartOrEndOpStore() { - c.callTestStartOrEndOpStore(func(params *tTempopTestStartOrEndOpStoreParams) (retVal interface{}, errCode string, err error) { - var vendorIDList []int - var storeIDList []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList); err == nil { - retVal, err = misc.StartOrEndOpStore(params.Ctx, params.StartOrEndStore, vendorIDList, storeIDList, int16(params.StartTime), int16(params.EndTime), params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 京西平台和其他平台商品的对比 -// @Description 京西平台和其他平台商品的对比 -// @Param token header string true "认证token" -// @Param vendorIDs formData string false "运营商ID列表(京东0 美团1 饿百3)" -// @Param storeIDs formData string false "京西门店ID列表" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CheckSkuDiffBetweenJxAndVendor [post] -func (c *TempOpController) CheckSkuDiffBetweenJxAndVendor() { - c.callCheckSkuDiffBetweenJxAndVendor(func(params *tTempopCheckSkuDiffBetweenJxAndVendorParams) (retVal interface{}, errCode string, err error) { - var vendorIDList []int - var storeIDList []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList); err == nil { - cms.CheckSkuDiffBetweenJxAndVendor(params.Ctx, vendorIDList, storeIDList) - } - - return retVal, "", err - }) -} - -// @Title 京西平台和其他平台商品的对比Test -// @Description 对比Test -// @Param token header string true "认证token" -// @Param vendorIDs formData string false "运营商ID列表(京东0 美团1 饿百3)" -// @Param storeIDs formData string false "京西门店ID列表" -// @Success 200 {object} controllers.CallResult -// @Failure 404 User not found -// @router /StoreSkuCheckDiff [post] -func (c *TempOpController) StoreSkuCheckDiff() { - c.callCheckSkuDiffBetweenJxAndVendor(func(params *tTempopCheckSkuDiffBetweenJxAndVendorParams) (retVal interface{}, errCode string, err error) { - var vendorIDList []int - var storeIDList []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList); err == nil { - cms.TestDiff(params.Ctx, vendorIDList, storeIDList) - } - return retVal, "", err - }) -} - -// @Title 把所有营业的门店,京西商城门店都打开,默认范围3km,默认100-100京西价格套餐 -// @Description 对比Test -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 404 User not found -// @router /StoreOpenAll [post] -func (c *TempOpController) StoreOpenAll() { - c.callCheckSkuDiffBetweenJxAndVendor(func(params *tTempopCheckSkuDiffBetweenJxAndVendorParams) (retVal interface{}, errCode string, err error) { - var vendorIDList []int - var storeIDList []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList); err == nil { - cms.StoreOpenAll(params.Ctx) - } - return retVal, "", err - }) -} - -// @Title 通过订单创建消费者用户 -// @Description 通过订单创建消费者用户 -// @Param token header string true "认证token" -// @Param fromDate formData string true "开始日期" -// @Param vendorIDs formData string false "运营商ID列表(京东0 美团1 饿百3)" -// @Param toDate formData string false "结束日期(缺省不限制)" -// @Param isForce formData bool false "是否强制" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateConsumerFromOrders [post] -func (c *TempOpController) CreateConsumerFromOrders() { - c.callCreateConsumerFromOrders(func(params *tTempopCreateConsumerFromOrdersParams) (retVal interface{}, errCode string, err error) { - var vendorIDs []int - timeList, err := jxutils.BatchStr2Time(params.FromDate, params.ToDate) - if err == nil { - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs); err == nil { - retVal, err = tempop.CreateConsumerFromOrders(params.Ctx, vendorIDs, timeList[0], timeList[1], params.IsForce, params.IsAsync, params.IsContinueWhenError) - } - } - return retVal, "", err - }) -} - -// @Title 触犯红线通知 -// @Description 触犯红线通知 -// @Param token header string true "认证token" -// @Param storeIDs formData string false "门店列表" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CheckStoreAlert [post] -func (c *TempOpController) CheckStoreAlert() { - c.callCheckStoreAlert(func(params *tTempopCheckStoreAlertParams) (retVal interface{}, errCode string, err error) { - var storeIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil { - misc.CheckStoreAlert(params.Ctx, storeIDs) - } - return retVal, "", err - }) -} - -// @Title 修复美团商品分类(emoji) -// @Description 修复美团商品分类(emoji) -// @Param token header string true "认证token" -// @Param mtwmStoreIDs formData string false "门店列表" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /FixMtwmCategory [post] -func (c *TempOpController) FixMtwmCategory() { - c.callFixMtwmCategory(func(params *tTempopFixMtwmCategoryParams) (retVal interface{}, errCode string, err error) { - var mtwmStoreIDs []int - if err = jxutils.Strings2Objs(params.MtwmStoreIDs, &mtwmStoreIDs); err == nil { - retVal, err = tempop.FixMtwmCategory(params.Ctx, mtwmStoreIDs, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 从饿百店建商品 -// @Description 从饿百店建商品 -// @Param token header string true "认证token" -// @Param baiduShopID formData int true "skuNameID" -// @Param isAsync formData bool false "是否异步操作" -// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /BuildSkuFromEbaiStore [post] -func (c *TempOpController) BuildSkuFromEbaiStore() { - c.callBuildSkuFromEbaiStore(func(params *tTempopBuildSkuFromEbaiStoreParams) (retVal interface{}, errCode string, err error) { - retVal, err = tempop.BuildSkuFromEbaiStore(params.Ctx, int64(params.BaiduShopID), params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) -} - -// @Title 上传京东商城图片 -// @Description 上传京东商城图片 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UploadJdsImage [post] -func (c *TempOpController) UploadJdsImage() { - c.callUploadJdsImage(func(params *tTempopUploadJdsImageParams) (retVal interface{}, errCode string, err error) { - err = tempop.UploadJdsImage(params.Ctx) - return retVal, "", err - }) -} - -// @Title 京西刷新调价包和门店价格 -// @Description 京西刷新调价包和门店价格 -// @Param token header string true "认证token" -// @Param storeID formData int false "门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshJXPriceChange [post] -func (c *TempOpController) RefreshJXPriceChange() { - c.callRefreshJXPriceChange(func(params *tTempopRefreshJXPriceChangeParams) (retVal interface{}, errCode string, err error) { - retVal, err = tempop.RefreshJXPriceChange(params.Ctx, params.StoreID) - return retVal, "", err - }) -} diff --git a/controllers/weimob_callback.go b/controllers/weimob_callback.go deleted file mode 100644 index ff3c8b5b5..000000000 --- a/controllers/weimob_callback.go +++ /dev/null @@ -1,49 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/baseapi/platformapi/weimobapi" - "git.rosy.net.cn/jx-callback/business/cs" - "git.rosy.net.cn/jx-callback/business/jxutils/tasks" - "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego" -) - -type WeimobController struct { - beego.Controller -} - -func (c *WeimobController) onCallbackMsg() { - if true { //c.Ctx.Input.Method() == http.MethodPost { - msg, callbackResponse := api.WeimobAPI.GetCallbackMsg(c.Ctx.Input.RequestBody) - if callbackResponse == nil { - // callbackResponse = wsc.OnCallbackMsg(msg) - callbackResponse = cs.OnCallbackMsg(msg) - } - if callbackResponse == nil { - callbackResponse = weimobapi.SuccessResponse - } - c.Data["json"] = callbackResponse - c.ServeJSON() - } else { - c.Abort("404") - } -} - -func (c *WeimobController) Code() { - globals.SugarLogger.Debugf("WeimobController code, code:%s, state:%s", c.GetString("code"), c.GetString("state")) - state := c.GetString("state") - if state == globals.WeimobStateSecret { // 防止有人故意搞坏,添加一个secret - code := c.GetString("code") - token, err := api.WeimobAPI.RefreshTokenByCode(code, globals.WeimobCallbackURL+"/code") - if err == nil { - tasks.SaveWeimobToken(token) - } else { - globals.SugarLogger.Warnf("RefreshTokenByCode failed with error:%v", err) - } - } -} - -func (c *WeimobController) Msg() { - c.onCallbackMsg() -} diff --git a/controllers/weixin_callback.go b/controllers/weixin_callback.go deleted file mode 100644 index 65933f7ee..000000000 --- a/controllers/weixin_callback.go +++ /dev/null @@ -1,28 +0,0 @@ -package controllers - -import ( - "net/http" - - "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego" -) - -type WeixinController struct { - beego.Controller -} - -func (c *WeixinController) Msg() { - if c.Ctx.Input.Method() == http.MethodGet { - signature := c.GetString("signature") - timestamp := c.GetString("timestamp") - nonce := c.GetString("nonce") - echostr := c.GetString("echostr") - isValid := api.WeixinAPI.ValidateWXCallbackURL(signature, timestamp, nonce) - globals.SugarLogger.Debugf("weixin URL check is:%t", isValid) - c.Ctx.WriteString(echostr) - } else { - c.Data["json"] = "ok" - c.ServeJSON() - } -} diff --git a/controllers/wxpay_callback.go b/controllers/wxpay_callback.go deleted file mode 100644 index 5ae1a1583..000000000 --- a/controllers/wxpay_callback.go +++ /dev/null @@ -1,41 +0,0 @@ -package controllers - -import ( - "fmt" - "net/http" - - "git.rosy.net.cn/baseapi/platformapi/wxpayapi" - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx" - "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego" -) - -type WXPayController struct { - beego.Controller -} - -func (c *WXPayController) Msg() { - if c.Ctx.Input.Method() == http.MethodPost { - msg, callbackResponse := api.WxpayAPI.GetCallbackMsg(c.Ctx.Request) - globals.SugarLogger.Debugf("wxpayapi callback msg:%s, callbackResponse:%s, %t", utils.Format4Output(msg, true), utils.Format4Output(callbackResponse, true), callbackResponse == nil) - var err error - if callbackResponse == nil { - if msg.MsgType == wxpayapi.MsgTypeUnkown { - err = fmt.Errorf("未知的微信支付回调类型:%d", msg.MsgType) - } else { - err = localjx.OnWxPayCallback(msg) - } - } - if callbackResponse == nil { - callbackResponse = wxpayapi.SuccessResponse - } else if err != nil { - callbackResponse = wxpayapi.Err2CallbackResponse(err, "") - } - c.Data["xml"] = callbackResponse - c.ServeXML() - } else { - c.Abort("404") - } -} diff --git a/controllers/yonghui.go b/controllers/yonghui.go deleted file mode 100644 index c6bd95451..000000000 --- a/controllers/yonghui.go +++ /dev/null @@ -1,94 +0,0 @@ -package controllers - -import ( - "io" - - "git.rosy.net.cn/jx-callback/business/jxstore/yonghui" - "git.rosy.net.cn/jx-callback/business/jxutils" - "github.com/astaxie/beego" -) - -//读取永辉excelAPI -type YongHuiController struct { - beego.Controller -} - -// @Title 读取永辉excel文件 -// @Description 读取永辉excel文件 -// @Param token header string true "认证token" -// @Param isAsync query bool true "是否异步,缺省是同步" -// @Param isContinueWhenError query bool true "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /LoadExcelByYongHui [post,get] -func (c *YongHuiController) LoadExcelByYongHui() { - if c.Ctx.Input.IsGet() { - w := c.Ctx.ResponseWriter - // 上传页面 - w.Header().Add("Content-Type", "text/html") - w.WriteHeader(200) - html := ` -
- Send this file: - -
- ` - io.WriteString(w, html) - } else if c.Ctx.Input.IsPost() { - c.callLoadExcelByYongHui(func(params *tYonghuiLoadExcelByYongHuiParams) (retVal interface{}, errCode string, err error) { - r := c.Ctx.Request - files := r.MultipartForm.File["userfiles"] - retVal, err = yonghui.LoadExcelByYongHui(params.Ctx, files, params.IsAsync, params.IsContinueWhenError) - return retVal, "", err - }) - } -} - -// @Title 根据微盟商品更新京西价格 -// @Description 根据微盟商品更新京西价格 -// @Param token header string true "认证token" -// @Param storeIDs formData string true "门店ID列表" -// @Param isAsync formData bool true "是否异步,缺省是同步" -// @Param isContinueWhenError formData bool true "单个同步失败是否继续,缺省false" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateJxPriceByWeimob [post] -func (c *YongHuiController) UpdateJxPriceByWeimob() { - c.callUpdateJxPriceByWeimob(func(params *tYonghuiUpdateJxPriceByWeimobParams) (retVal interface{}, errCode string, err error) { - var storeIDList []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil { - retVal, err = yonghui.UpdateJxPriceByWeimob(params.Ctx, storeIDList, params.IsAsync, params.IsContinueWhenError) - } - return retVal, "", err - }) -} - -// @Title 查询微盟订单 -// @Description 查询微盟订单 -// @Param token header string true "认证token" -// @Param keyword query string false "查询关键字" -// @Param fromTime formData string false "订单起始时间 (yyyy-mm-dd 00:00:00)" -// @Param toTime formData string false "订单结束时间 (yyyy-mm-dd 00:00:00)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetWeimobOrders [post] -func (c *YongHuiController) GetWeimobOrders() { - c.callGetWeimobOrders(func(params *tYonghuiGetWeimobOrdersParams) (retVal interface{}, errCode string, err error) { - retVal, err = yonghui.GetWeimobOrders(params.Ctx, params.FromTime, params.ToTime, params.MapData) - return retVal, "", err - }) -} - -// @Title 根据微盟订单号生成Excel -// @Description 根据微盟订单号生成Excel -// @Param token header string true "认证token" -// @Param orderNo formData string true "订单号" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetWeimobOrdersExcel [post] -func (c *YongHuiController) GetWeimobOrdersExcel() { - c.callGetWeimobOrdersExcel(func(params *tYonghuiGetWeimobOrdersExcelParams) (retVal interface{}, errCode string, err error) { - retVal, err = yonghui.GetWeimobOrdersExcel(params.Ctx, params.OrderNo) - return retVal, "", err - }) -} diff --git a/main.go b/main.go index 51f9f9eec..ffc814808 100644 --- a/main.go +++ b/main.go @@ -6,29 +6,15 @@ import ( "net/http" _ "net/http/pprof" "os" - "time" - - "git.rosy.net.cn/jx-callback/business/partner/purchase/jdshop" - - "git.rosy.net.cn/jx-callback/business/partner/purchase/yb" "github.com/astaxie/beego" - "git.rosy.net.cn/baseapi/platformapi/dingdingapi" - "git.rosy.net.cn/baseapi/utils" - _ "git.rosy.net.cn/jx-callback/globals/api/apimanager" - "git.rosy.net.cn/jx-callback/business/jxcallback/orderman" - "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch" // 导入缺省订单调度器 - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxstore/misc" + // 导入缺省订单调度器 + "git.rosy.net.cn/jx-callback/business/jxutils/tasks" - "git.rosy.net.cn/jx-callback/business/partner/purchase/ebai" - "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm" "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" - "git.rosy.net.cn/jx-callback/globals/api2" "git.rosy.net.cn/jx-callback/globals/beegodb" _ "git.rosy.net.cn/jx-callback/business/partner/printer/feie" @@ -64,24 +50,6 @@ var ( func Init() { beegodb.Init() - if globals.EnableWXAuth2 { - api2.Init() - } - - defsch.Init() - buildTime, err := time.ParseInLocation(time.RFC3339, BuildDate, time.UTC) - if err == nil { - buildTime = buildTime.Local() - } - cms.InitServiceInfo(Version, buildTime, GitCommit) - - if globals.IsProductEnv() { - ebai.CurPurchaseHandler.StartRefreshComment() - mtwm.CurPurchaseHandler.StartRefreshComment() - yb.CurPurchaseHandler.StartRefreshComment() - jdshop.CurPurchaseHandler.StartRefreshComment() - } - misc.Init() } // 返回true表示非运行服务 @@ -140,38 +108,10 @@ func main() { globals.SugarLogger.Errorf("RefreshWeixin3Token failed with error:%s", err) return } - // if err := tasks.RefreshWeimobToken(); err != nil { - // globals.SugarLogger.Errorf("RefreshWeimobToken failed with error:%s", err) - // return - // } - if err := tasks.RefreshYilianyunToken(); err != nil { - globals.SugarLogger.Errorf("RefreshYilianyunToken failed with error:%s", err) - return - } if err := tasks.RefreshPushToken(); err != nil { globals.SugarLogger.Errorf("RefreshPushToken failed with error:%s", err) return } - // if globals.IsProductEnv() { - // orderman.SaveJdsOrders(nil, time.Now().Add(-2*time.Hour), time.Now()) - // } - orderman.LoadPendingOrders() - - // 延时的原因是等回调准备好 - if globals.IsProductEnv() || beego.BConfig.RunMode == "beta" { - utils.AfterFuncWithRecover(2*time.Second, func() { - if err := tasks.RefreshDingDingToken(); err != nil { - globals.SugarLogger.Errorf("RefreshDingDingToken failed with error:%s", err) - return - } - if globals.IsProductEnv() { - api.DingDingAPI.DeleteCallback() - if err := api.DingDingAPI.RegisterCallback([]string{dingdingapi.CBTagUserAddOrg, dingdingapi.CBTagUserModifyOrg, dingdingapi.CBTagUserLeaveOrg}, beego.AppConfig.DefaultString("dingdingCallbackToken", ""), beego.AppConfig.DefaultString("dingdingCallbackAESKey", ""), beego.AppConfig.DefaultString("dingdingCallbackURL", "")); err != nil { - globals.SugarLogger.Warnf("dingding RegisterCallback failed with error:%v", err) - } - } - }) - } if beego.BConfig.RunMode != "prod" { beego.BConfig.WebConfig.DirectoryIndex = true diff --git a/routers/router.go b/routers/router.go index 529322cb6..770e19cd2 100644 --- a/routers/router.go +++ b/routers/router.go @@ -16,41 +16,6 @@ import ( func init() { ns := beego.NewNamespace("/v2", - beego.NSNamespace("/order", - beego.NSInclude( - &controllers.OrderController{}, - ), - ), - beego.NSNamespace("/jxorder", - beego.NSInclude( - &controllers.JxOrderController{}, - ), - ), - beego.NSNamespace("/sku", - beego.NSInclude( - &controllers.SkuController{}, - ), - ), - beego.NSNamespace("/store", - beego.NSInclude( - &controllers.StoreController{}, - ), - ), - // beego.NSNamespace("/auth", - // beego.NSInclude( - // &controllers.AuthController{}, - // ), - // ), - beego.NSNamespace("/cms", - beego.NSInclude( - &controllers.CmsController{}, - ), - ), - // beego.NSNamespace("/user", - // beego.NSInclude( - // &controllers.UserController{}, - // ), - // ), beego.NSNamespace("/store/sku", beego.NSInclude( &controllers.StoreSkuController{}, @@ -61,26 +26,6 @@ func init() { &controllers.TaskController{}, ), ), - beego.NSNamespace("/financial", - beego.NSInclude( - &controllers.FinancialController{}, - ), - ), - beego.NSNamespace("/sync", - beego.NSInclude( - &controllers.SyncController{}, - ), - ), - beego.NSNamespace("/initdata", - beego.NSInclude( - &controllers.InitDataController{}, - ), - ), - beego.NSNamespace("/msg", - beego.NSInclude( - &controllers.MsgController{}, - ), - ), beego.NSNamespace("/auth2", beego.NSInclude( &controllers.Auth2Controller{}, @@ -91,78 +36,9 @@ func init() { &controllers.User2Controller{}, ), ), - beego.NSNamespace("/ddapi", - beego.NSInclude( - &controllers.DDAPIController{}, - ), - ), - beego.NSNamespace("/tempop", - beego.NSInclude( - &controllers.TempOpController{}, - ), - ), - beego.NSNamespace("/sys", - beego.NSInclude( - &controllers.SysController{}, - ), - ), - beego.NSNamespace("/netspider", - beego.NSInclude( - &controllers.NetSpiderController{}, - ), - ), - beego.NSNamespace("/act", - beego.NSInclude( - &controllers.ActController{}, - ), - ), - beego.NSNamespace("/jxshop", - beego.NSInclude( - &controllers.JxShopController{}, - ), - ), - beego.NSNamespace("/foodrecipe", - beego.NSInclude( - &controllers.FoodRecipeController{}, - ), - ), - beego.NSNamespace("/report", - beego.NSInclude( - &controllers.ReportController{}, - ), - ), - beego.NSNamespace("/yonghui", - beego.NSInclude( - &controllers.YongHuiController{}, - ), - ), - beego.NSNamespace("/event", - beego.NSInclude( - &controllers.EventController{}, - ), - ), - beego.NSNamespace("/power", - beego.NSInclude( - &controllers.PowerController{}, - ), - ), ) beego.AddNamespace(ns) - - beego.AutoRouter(&controllers.DjswController{}) - beego.AutoRouter(&controllers.MtpsController{}) - beego.AutoRouter(&controllers.ElemeController{}) - beego.AutoRouter(&controllers.DadaDeliveryController{}) - beego.AutoRouter(&controllers.EbaiController{}) - beego.AutoRouter(&controllers.MtwmController{}) - beego.AutoRouter(&controllers.WeimobController{}) - beego.AutoRouter(&controllers.WeixinController{}) - beego.AutoRouter(&controllers.DingDingController{}) - beego.AutoRouter(&controllers.WXPayController{}) - beego.AutoRouter(&controllers.Djsw2Controller{}) beego.AutoRouter(&controllers.TongLianController{}) - beego.AutoRouter(&controllers.EclpController{}) - beego.AutoRouter(&controllers.JdsController{}) // 如下都是用于检测存活的空接口 beego.Any("/", func(ctx *beecontext.Context) {